Compare commits

...

3 Commits

Author SHA1 Message Date
Stefan Bühler 424e1a37f8 [core] Reset con->out (response body) queue counters (used by mod_accesslog) for keep-alive 8 months ago
Stefan Bühler d544ee105d [core] docs say empty log targets request not logging; actually implement that (went to stderr) 8 months ago
Stefan Bühler 7a343d4765 [mod_acceslog]: fix log target reference in docs 8 months ago
  1. 2
      doc/mod_accesslog.xml
  2. 3
      src/main/connection.c
  3. 22
      src/main/log.c

2
doc/mod_accesslog.xml

@ -54,7 +54,7 @@
<parameter name="target" />
<default><text>logging disabled</text></default>
<description>
<html>Enable logging by setting a log target. Supports the same log targets as <a href="plugin_clore.html#plugin_core__action_log">log</a>.</html>
<html>Enable logging by setting a log target. Supports the same log targets as <a href="plugin_core.html#plugin_core__action_log">log</a>.</html>
</description>
<example>
<config>

3
src/main/connection.c

@ -845,6 +845,9 @@ static void li_connection_reset_keep_alive(liConnection *con) {
li_stream_disconnect(&con->out);
li_stream_disconnect_dest(&con->in);
con->out.out->is_closed = FALSE;
/* reset con->out (== vr->coninfo->resp) counters. con->in is reset on keep-alive "reopen" */
con->out.out->bytes_out = 0;
con->out.out->bytes_in = con->out.out->length;
memset(&con->in_chunked_decode_state, 0, sizeof(con->in_chunked_decode_state));

22
src/main/log.c

@ -193,6 +193,11 @@ void li_log_context_set(liLogContext *context, liLogMap *log_map) {
gboolean li_log_write_direct(liServer *srv, liWorker *wrk, GString *path, GString *msg) {
liLogEntry *log_entry;
if (!path || path->len == 0) {
/* ignore empty log targets */
return TRUE;
}
log_entry = g_slice_new(liLogEntry);
log_entry->path = g_string_new_len(GSTR_LEN(path));
log_entry->level = 0;
@ -231,20 +236,20 @@ gboolean li_log_write(liServer *srv, liWorker *wrk, liLogContext *context, liLog
if (log_map != NULL && log_level < LI_LOG_LEVEL_COUNT) {
path = log_map->targets[log_level];
} else {
/* no log map or invalid log level */
return FALSE;
}
if (!path || path->len == 0) {
/* log-level is ignored */
return TRUE;
}
log_line = g_string_sized_new(63);
va_start(ap, fmt);
g_string_vprintf(log_line, fmt, ap);
va_end(ap);
if (!path) {
li_log_write_stderr(srv, log_line->str, TRUE);
g_string_free(log_line, TRUE);
return TRUE;
}
switch (g_atomic_int_get(&srv->state)) {
case LI_SERVER_INIT:
case LI_SERVER_LOADING:
@ -350,7 +355,10 @@ static void log_watcher_cb(liEventBase *watcher, int events) {
log = log_open(srv, log_entry->path);
if (NULL == log || -1 == log->fd) {
if (NULL == log) {
/* explicit empty target, ignore */
} else if (-1 == log->fd) {
/* failed opening log file */
li_log_write_stderr(srv, msg->str, TRUE);
goto next;
}

Loading…
Cancel
Save