mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: Allow setting memory backlog for logfiles
This commit is contained in:
parent
73dce0a692
commit
de270c535d
@ -68,6 +68,7 @@
|
||||
#define CONFIG_DEFAULT_ACCESS_LOG "access.log"
|
||||
#define CONFIG_DEFAULT_ERROR_LOG "error.log"
|
||||
#define CONFIG_DEFAULT_LOG_LEVEL ICECAST_LOGLEVEL_INFO
|
||||
#define CONFIG_DEFAULT_LOG_LINES_KEPT 64
|
||||
#define CONFIG_DEFAULT_CHROOT 0
|
||||
#define CONFIG_DEFAULT_CHUID 0
|
||||
#define CONFIG_DEFAULT_USER NULL
|
||||
@ -912,6 +913,12 @@ static void _set_defaults(ice_config_t *configuration)
|
||||
->error_log = (char *) xmlCharStrdup(CONFIG_DEFAULT_ERROR_LOG);
|
||||
configuration
|
||||
->loglevel = CONFIG_DEFAULT_LOG_LEVEL;
|
||||
configuration
|
||||
->playlist_log_lines_kept = CONFIG_DEFAULT_LOG_LINES_KEPT;
|
||||
configuration
|
||||
->access_log_lines_kept = CONFIG_DEFAULT_LOG_LINES_KEPT;
|
||||
configuration
|
||||
->error_log_lines_kept = CONFIG_DEFAULT_LOG_LINES_KEPT;
|
||||
configuration
|
||||
->chroot = CONFIG_DEFAULT_CHROOT;
|
||||
configuration
|
||||
@ -2394,6 +2401,28 @@ static void _parse_logging(xmlDocPtr doc,
|
||||
} else {
|
||||
ICECAST_LOG_WARN("<logarchive> must not be empty.");
|
||||
}
|
||||
} else if (xmlStrcmp(node->name, XMLSTR("memorybacklog")) == 0) {
|
||||
int val = CONFIG_DEFAULT_LOG_LINES_KEPT;
|
||||
char *logfile = (char *)xmlGetProp(node, XMLSTR("logfile"));
|
||||
|
||||
__read_int(doc, node, &val, "<memorybacklog> must not be empty.");
|
||||
|
||||
if (logfile) {
|
||||
if (!strcmp(logfile, "error")) {
|
||||
configuration->error_log_lines_kept = val;
|
||||
} else if (!strcmp(logfile, "access")) {
|
||||
configuration->access_log_lines_kept = val;
|
||||
} else if (!strcmp(logfile, "playlist")) {
|
||||
configuration->playlist_log_lines_kept = val;
|
||||
} else {
|
||||
ICECAST_LOG_WARN("Invalid logfile for <memorybacklog>: %H", logfile);
|
||||
}
|
||||
xmlFree(logfile);
|
||||
} else {
|
||||
configuration->error_log_lines_kept = val;
|
||||
configuration->access_log_lines_kept = val;
|
||||
configuration->playlist_log_lines_kept = val;
|
||||
}
|
||||
}
|
||||
} while ((node = node->next));
|
||||
}
|
||||
|
@ -261,6 +261,9 @@ struct ice_config_tag {
|
||||
int loglevel;
|
||||
int logsize;
|
||||
int logarchive;
|
||||
size_t access_log_lines_kept;
|
||||
size_t error_log_lines_kept;
|
||||
size_t playlist_log_lines_kept;
|
||||
|
||||
config_tls_context_t tls_context;
|
||||
|
||||
|
@ -249,4 +249,8 @@ void restart_logging (ice_config_t *config)
|
||||
log_set_archive_timestamp (playlistlog, config->logarchive);
|
||||
log_reopen (playlistlog);
|
||||
}
|
||||
|
||||
log_set_lines_kept(errorlog, config->error_log_lines_kept);
|
||||
log_set_lines_kept(accesslog, config->access_log_lines_kept);
|
||||
log_set_lines_kept(playlistlog, config->playlist_log_lines_kept);
|
||||
}
|
||||
|
@ -343,6 +343,10 @@ static int _start_logging(void)
|
||||
log_set_level(accesslog, 4);
|
||||
log_set_level(playlistlog, 4);
|
||||
|
||||
log_set_lines_kept(errorlog, config->error_log_lines_kept);
|
||||
log_set_lines_kept(accesslog, config->access_log_lines_kept);
|
||||
log_set_lines_kept(playlistlog, config->playlist_log_lines_kept);
|
||||
|
||||
if (errorlog >= 0 && accesslog >= 0) return 1;
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user