From 3cc93758baae354d0d99955106cf4e6a83c885f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gomez?= Date: Sun, 4 Feb 2024 15:56:01 +0900 Subject: [PATCH] Add timestamp_format global option --- src/bip.c | 6 +++++- src/conf.y | 3 ++- src/lex.l | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bip.c b/src/bip.c index 52930fc..5c8bbfe 100644 --- a/src/bip.c +++ b/src/bip.c @@ -161,7 +161,8 @@ void conf_die(bip_t *bip, char *fmt, ...) error = bip_realloc(error, size); } va_start(ap, fmt); - mylog(LOG_ERROR, fmt, ap); + /* log timestamp format is a conf option, we cannot log with time */ + mylog_nots(LOG_ERROR, fmt, ap); va_end(ap); } @@ -1041,6 +1042,9 @@ int fireup(bip_t *bip, FILE *conf) case LEX_LOG_LEVEL: conf_log_level = t->ndata; break; + case LEX_TIMESTAMP_FORMAT: + MOVE_STRING(conf_timestamp_format, t->pdata); + break; case LEX_IP: MOVE_STRING(conf_ip, t->pdata); break; diff --git a/src/conf.y b/src/conf.y index d12cdda..dcaf822 100644 --- a/src/conf.y +++ b/src/conf.y @@ -69,7 +69,7 @@ struct tuple *tuple_l_new(int type, void *p) %} -%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_SSL_CLIENT_CERTFILE LEX_CIPHERS LEX_CSS_CIPHERS LEX_DEFAULT_CIPHERS LEX_DH_PARAM LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_TIMESTAMP LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_WRITE_OIDENTD LEX_OIDENTD_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_BLRESET_CONNECTION LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN LEX_BIP_USE_NOTICE LEX_CSS_PEM LEX_AUTOJOIN_ON_KICK LEX_IGNORE_CAPAB LEX_RECONN_TIMER LEX_SASL_USERNAME LEX_SASL_PASSWORD LEX_SASL_MECHANISM +%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_SSL_CLIENT_CERTFILE LEX_CIPHERS LEX_CSS_CIPHERS LEX_DEFAULT_CIPHERS LEX_DH_PARAM LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_TIMESTAMP LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_WRITE_OIDENTD LEX_OIDENTD_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_BLRESET_CONNECTION LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN LEX_BIP_USE_NOTICE LEX_CSS_PEM LEX_AUTOJOIN_ON_KICK LEX_IGNORE_CAPAB LEX_RECONN_TIMER LEX_SASL_USERNAME LEX_SASL_PASSWORD LEX_SASL_MECHANISM LEX_TIMESTAMP_FORMAT %union { int number; @@ -108,6 +108,7 @@ command: | LEX_LOG_SYNC_INTERVAL LEX_EQ LEX_INT { $$ = tuple_i_new( LEX_LOG_SYNC_INTERVAL, $3); } | LEX_PID_FILE LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_PID_FILE, $3); } + | LEX_TIMESTAMP_FORMAT LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_TIMESTAMP_FORMAT, $3); } | LEX_WRITE_OIDENTD LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_WRITE_OIDENTD, $3); } | LEX_OIDENTD_FILE LEX_EQ LEX_STRING { $$ = tuple_s_new(LEX_OIDENTD_FILE, $3); } /* deprecated */ diff --git a/src/lex.l b/src/lex.l index 1347b54..0adb524 100644 --- a/src/lex.l +++ b/src/lex.l @@ -90,6 +90,7 @@ list_t *parse_conf(FILE *file, int *err) "log_level" { return LEX_LOG_LEVEL; } "log_root" { return LEX_LOG_ROOT; } "log_format" { return LEX_LOG_FORMAT; } +"timestamp_format" { return LEX_TIMESTAMP_FORMAT; } "backlog_lines" { return LEX_BACKLOG_LINES; } "backlog_timestamp" { return LEX_BACKLOG_TIMESTAMP; } "backlog_no_timestamp" { return LEX_BACKLOG_NO_TIMESTAMP; }