mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-06-30 22:18:19 -04:00
Feature: Handle gracefully when a logfile is not configured
This commit is contained in:
parent
8d3189bc9c
commit
2e377a3e31
28
src/admin.c
28
src/admin.c
@ -1273,16 +1273,16 @@ static void command_show_log (client_t *client, source_t *source, adm
|
|||||||
|
|
||||||
COMMAND_OPTIONAL(client, "logfile", logfilestring);
|
COMMAND_OPTIONAL(client, "logfile", logfilestring);
|
||||||
|
|
||||||
if (!logfilestring || !strcmp(logfilestring, "error")) {
|
if (!logfilestring) {
|
||||||
logfilestring = "error";
|
logfilestring = "error";
|
||||||
logid = errorlog;
|
logid = errorlog;
|
||||||
} else if (!strcmp(logfilestring, "access")) {
|
|
||||||
logid = accesslog;
|
|
||||||
} else if (!strcmp(logfilestring, "playlist")) {
|
|
||||||
logid = playlistlog;
|
|
||||||
} else {
|
} else {
|
||||||
logfilestring = "error";
|
logid = logging_str2logid(logfilestring);
|
||||||
logid = errorlog;
|
}
|
||||||
|
|
||||||
|
if (logid < 0) {
|
||||||
|
client_send_error_by_id(client, ICECAST_ERROR_FSERV_FILE_NOT_FOUND);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
report = client_get_reportxml("b20a2bf2-1278-448c-81f3-58183d837a86", NULL, NULL);
|
report = client_get_reportxml("b20a2bf2-1278-448c-81f3-58183d837a86", NULL, NULL);
|
||||||
@ -1298,7 +1298,8 @@ static void command_show_log (client_t *client, source_t *source, adm
|
|||||||
reportxml_node_set_attribute(loglist_value_list, "type", "list");
|
reportxml_node_set_attribute(loglist_value_list, "type", "list");
|
||||||
|
|
||||||
for (i = 0; i < (sizeof(logs)/sizeof(*logs)); i++) {
|
for (i = 0; i < (sizeof(logs)/sizeof(*logs)); i++) {
|
||||||
reportxml_helper_add_value_string(loglist_value_list, NULL, logs[i]);
|
if (logging_str2logid(logs[i]) >= 0)
|
||||||
|
reportxml_helper_add_value_string(loglist_value_list, NULL, logs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
reportxml_node_add_child(resource, loglist_value_list);
|
reportxml_node_add_child(resource, loglist_value_list);
|
||||||
@ -1313,6 +1314,7 @@ static void command_show_log (client_t *client, source_t *source, adm
|
|||||||
|
|
||||||
logfile = reportxml_node_new(REPORTXML_NODE_TYPE_VALUE, NULL, NULL, NULL);
|
logfile = reportxml_node_new(REPORTXML_NODE_TYPE_VALUE, NULL, NULL, NULL);
|
||||||
reportxml_node_set_attribute(logfile, "type", "structure");
|
reportxml_node_set_attribute(logfile, "type", "structure");
|
||||||
|
reportxml_helper_add_value_int(logfile, "logid", logid);
|
||||||
|
|
||||||
reportxml_helper_add_value_string(logfile, "logfile", logfilestring);
|
reportxml_helper_add_value_string(logfile, "logfile", logfilestring);
|
||||||
|
|
||||||
@ -1320,11 +1322,13 @@ static void command_show_log (client_t *client, source_t *source, adm
|
|||||||
reportxml_node_set_attribute(parent, "type", "list");
|
reportxml_node_set_attribute(parent, "type", "list");
|
||||||
reportxml_node_set_attribute(parent, "member", "lines");
|
reportxml_node_set_attribute(parent, "member", "lines");
|
||||||
loglines = log_contents_array(logid);
|
loglines = log_contents_array(logid);
|
||||||
for (i = 0; loglines[i]; i++) {
|
if (loglines) {
|
||||||
reportxml_helper_add_value_string(parent, NULL, loglines[i]);
|
for (i = 0; loglines[i]; i++) {
|
||||||
free(loglines[i]);
|
reportxml_helper_add_value_string(parent, NULL, loglines[i]);
|
||||||
|
free(loglines[i]);
|
||||||
|
}
|
||||||
|
free(loglines);
|
||||||
}
|
}
|
||||||
free(loglines);
|
|
||||||
reportxml_node_add_child(logfile, parent);
|
reportxml_node_add_child(logfile, parent);
|
||||||
refobject_unref(parent);
|
refobject_unref(parent);
|
||||||
|
|
||||||
|
@ -43,6 +43,23 @@ int errorlog = 0;
|
|||||||
int accesslog = 0;
|
int accesslog = 0;
|
||||||
int playlistlog = 0;
|
int playlistlog = 0;
|
||||||
|
|
||||||
|
int logging_str2logid(const char *str)
|
||||||
|
{
|
||||||
|
if (!str)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!strcmp(str, "error")) {
|
||||||
|
return errorlog;
|
||||||
|
} else if (!strcmp(str, "access")) {
|
||||||
|
return accesslog;
|
||||||
|
} else if (!strcmp(str, "playlist")) {
|
||||||
|
return playlistlog;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* Since strftime's %z option on win32 is different, we need
|
/* Since strftime's %z option on win32 is different, we need
|
||||||
to go through a few loops to get the same info as %z */
|
to go through a few loops to get the same info as %z */
|
||||||
|
@ -96,6 +96,8 @@ extern int playlistlog;
|
|||||||
|
|
||||||
#define LOGGING_FORMAT_CLF "%d/%b/%Y:%H:%M:%S %z"
|
#define LOGGING_FORMAT_CLF "%d/%b/%Y:%H:%M:%S %z"
|
||||||
|
|
||||||
|
int logging_str2logid(const char *str);
|
||||||
|
|
||||||
void logging_access(client_t *client);
|
void logging_access(client_t *client);
|
||||||
void logging_playlist(const char *mount, const char *metadata, long listeners);
|
void logging_playlist(const char *mount, const char *metadata, long listeners);
|
||||||
void logging_mark(const char *username, const char *role);
|
void logging_mark(const char *username, const char *role);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user