vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit fd1354d00e6a6a087df2a68463c6bd95b46b315a
parent 32cfaab5eefa1564b31819685a7b51f4a5025a59
Author: Daniel GarcĂ­a <dani-garcia@users.noreply.github.com>
Date:   Fri, 24 Jul 2020 16:42:10 +0200

Merge pull request #1067 from jjlin/log-time-fmt

Add config option for log timestamp format
Diffstat:
M.env.template | 4++++
Msrc/config.rs | 2++
Msrc/main.rs | 4++--
3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/.env.template b/.env.template @@ -44,6 +44,10 @@ ## Enable extended logging, which shows timestamps and targets in the logs # EXTENDED_LOGGING=true +## Timestamp format used in extended logging. +## Format specifiers: https://docs.rs/chrono/latest/chrono/format/strftime +# LOG_TIMESTAMP_FORMAT="%Y-%m-%d %H:%M:%S.%3f" + ## Logging to file ## It's recommended to also set 'ROCKET_CLI_COLORS=off' # LOG_FILE=/path/to/log diff --git a/src/config.rs b/src/config.rs @@ -329,6 +329,8 @@ make_config! { reload_templates: bool, true, def, false; /// Enable extended logging extended_logging: bool, false, def, true; + /// Log timestamp format + log_timestamp_format: String, true, def, "%Y-%m-%d %H:%M:%S.%3f".to_string(); /// Enable the log to output to Syslog use_syslog: bool, false, def, false; /// Log file path diff --git a/src/main.rs b/src/main.rs @@ -130,8 +130,8 @@ fn init_logging(level: log::LevelFilter) -> Result<(), fern::InitError> { if CONFIG.extended_logging() { logger = logger.format(|out, message, record| { out.finish(format_args!( - "{}[{}][{}] {}", - chrono::Local::now().format("[%Y-%m-%d %H:%M:%S]"), + "[{}][{}][{}] {}", + chrono::Local::now().format(&CONFIG.log_timestamp_format()), record.target(), record.level(), message