From a8fb0c40d3a0f26617bbbc5eea2381284d346f6b Mon Sep 17 00:00:00 2001 From: Arnaud Cornet Date: Sun, 5 Jul 2009 14:00:06 +0200 Subject: [PATCH] Support hour in log format. Mostly for debugging --- samples/bip.conf | 3 ++- src/log.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/bip.conf b/samples/bip.conf index 7988650..6761688 100644 --- a/samples/bip.conf +++ b/samples/bip.conf @@ -50,7 +50,8 @@ log_level = 3; # %Y -> 4 digit year # %m -> 2 digit month # %d -> 2 digit day -# %c -> destination (#chan, privates, ...) +# %h -> 2 digit hour of the day +# %c -> destination (#chan, nick, ...) #log_format = "%u/%n/%Y-%m/%c.%d.log"; # Sets the frequency (in seconds) of log syncing (real write to kernel) diff --git a/src/log.c b/src/log.c index 6fa16ce..f637a0f 100644 --- a/src/log.c +++ b/src/log.c @@ -133,7 +133,7 @@ void replace_var(char *str, char *var, char *value, unsigned int max) char *log_build_filename(log_t *logdata, const char *destination) { - char *logfile, year[5], day[3], month[3], *tmp, *logdir; + char *logfile, year[5], day[3], month[3], hour[2], *tmp, *logdir; struct tm *now; time_t s; char *dest = bip_strdup(destination); @@ -146,6 +146,7 @@ char *log_build_filename(log_t *logdata, const char *destination) snprintf(year, 5, "%04d", now->tm_year + 1900); snprintf(day, 3, "%02d", now->tm_mday); snprintf(month, 3, "%02d", now->tm_mon + 1); + snprintf(hour, 3, "%02d", now->tm_hour); snprintf(logfile, MAX_PATH_LEN, "%s/%s", conf_log_root, conf_log_format); replace_var(logfile, "%u", logdata->user->name, MAX_PATH_LEN); @@ -154,6 +155,7 @@ char *log_build_filename(log_t *logdata, const char *destination) replace_var(logfile, "%Y", year, MAX_PATH_LEN); replace_var(logfile, "%d", day, MAX_PATH_LEN); replace_var(logfile, "%m", month, MAX_PATH_LEN); + replace_var(logfile, "%h", hour, MAX_PATH_LEN); logdir = bip_strdup(logfile);