2
0
Fork 0

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
Change-Id: Id644a71c808c8a3c73e476fddb6022177de8dd5f
2021-02-28 12:38:33 +00:00
Stefan Bühler d544ee105d [core] docs say empty log targets request not logging; actually implement that (went to stderr)
Change-Id: If71dc0b309c4e8221ecef877202d9a1a571ad5c6
2021-02-28 13:28:00 +01:00
Stefan Bühler 7a343d4765 [mod_acceslog]: fix log target reference in docs
Change-Id: If390d666db5e4952a64d545eb77ddf6e8f7ed9df
2021-02-28 11:45:03 +01:00
3 changed files with 19 additions and 8 deletions

View File

@ -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>

View File

@ -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));

View File

@ -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;
}