1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-22 05:10:29 +01:00

Add config option for log timestamp format

Dieser Commit ist enthalten in:
Jeremy Lin 2020-07-22 21:50:49 -07:00
Ursprung 11845d9f5b
Commit d348f12a0e
3 geänderte Dateien mit 8 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -44,6 +44,10 @@
## Enable extended logging, which shows timestamps and targets in the logs ## Enable extended logging, which shows timestamps and targets in the logs
# EXTENDED_LOGGING=true # 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"
## Logging to file ## Logging to file
## It's recommended to also set 'ROCKET_CLI_COLORS=off' ## It's recommended to also set 'ROCKET_CLI_COLORS=off'
# LOG_FILE=/path/to/log # LOG_FILE=/path/to/log

Datei anzeigen

@ -329,6 +329,8 @@ make_config! {
reload_templates: bool, true, def, false; reload_templates: bool, true, def, false;
/// Enable extended logging /// Enable extended logging
extended_logging: bool, false, def, true; extended_logging: bool, false, def, true;
/// Log timestamp format
log_timestamp_format: String, true, def, "%Y-%m-%d %H:%M:%S".to_string();
/// Enable the log to output to Syslog /// Enable the log to output to Syslog
use_syslog: bool, false, def, false; use_syslog: bool, false, def, false;
/// Log file path /// Log file path

Datei anzeigen

@ -130,8 +130,8 @@ fn init_logging(level: log::LevelFilter) -> Result<(), fern::InitError> {
if CONFIG.extended_logging() { if CONFIG.extended_logging() {
logger = logger.format(|out, message, record| { logger = logger.format(|out, message, record| {
out.finish(format_args!( 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.target(),
record.level(), record.level(),
message message