invenia / Memento.jl

A flexible logging library for Julia
https://invenia.github.io/Memento.jl/latest
Other
87 stars 14 forks source link

Allow customising date format #175

Closed gasagna closed 3 years ago

gasagna commented 3 years ago

Hi,

thanks for the great package.

I need to log events with sub-second accuracy, but it looks like the date format is hard-coded by the constant DATE_FMT_STRING = "yyyy-mm-dd HH:MM:SS" in src/formatters.jl.

It would be nice if the date format string was fully customisable, for greater flexibility.

tpgillam commented 3 years ago

Hi @gasagna , this should now be doable with the new argument to DefaultFormatter in v1.2.0. For example:

DefaultFormatter("{date}"; date_fmt_string="yyyy-mm-dd HH:MM:SS.s")

will print just the datetime, including milliseconds.