summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthe xhr <xhr@giessen.ccc.de>2021-08-26 12:25:13 +0200
committerthe xhr <xhr@giessen.ccc.de>2021-08-26 12:25:13 +0200
commit56b35e42d570e4505081c2f1a9f8bc94704c7045 (patch)
tree1d33f50049046621264a5aeee0b048195679bad1
parent91d2ac5e163752e9b29c7a8884fc8b6888f4b7b6 (diff)
Use strftime() to have more apache like log messages
-rw-r--r--log.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/log.c b/log.c
index eb81019..6e07ccb 100644
--- a/log.c
+++ b/log.c
@@ -236,33 +236,31 @@ close_twind_logs(void)
void
log_access(const struct client_connection *cc, const char *fmt, ...)
{
+ char tmstr[29];
struct tm tm;
time_t t;
t = time(NULL);
tm = *localtime(&t);
- user_log(0, "%s - - [%d/%d/%d:%d:%d:%d %s] %s", cc->client_addr,
- tm.tm_mday, tm.tm_mon, tm.tm_year+1900,
- tm.tm_hour, tm.tm_min, tm.tm_sec,
- tm.tm_zone, fmt);
+ strftime(tmstr, sizeof(tmstr), "%d/%b/%Y:%H:%M:%S %Z", &tm);
+
+ user_log(0, "%s - - [%s] %s", cc->client_addr, tmstr, fmt);
}
void
log_error(const struct client_connection *cc, const char *fmt, ...)
{
+ char tmstr[29];
struct tm tm;
time_t t;
t = time(NULL);
tm = *localtime(&t);
+ strftime(tmstr, sizeof(tmstr), "%d/%b/%Y:%H:%M:%S %Z", &tm);
- user_log(1, "[%d/%d/%d:%d:%d:%d %s] [error] [client %s] %s",
- tm.tm_mday, tm.tm_mon, tm.tm_year+1900,
- tm.tm_hour, tm.tm_min, tm.tm_sec,
- tm.tm_zone,
- cc->client_addr,
- fmt);
+ user_log(1, "[%s] [error] [client %s] %s", tmstr,
+ cc->client_addr, fmt);
}
void
generated by cgit on OpenBSD