parent
68af35aff7
commit
a9e2537777
|
@ -36,13 +36,85 @@ log_cmd_t *get_cb_by_cmd(const char *cmd)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void logging_usage()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
char tmp_str[1024] = "";
|
||||||
|
fprintf(stdout, "-----------------------------------------------------------------------------------------\n");
|
||||||
|
fprintf(stdout, "usage of %s:", LOGGING_MODULE_NAME);
|
||||||
|
for (int i = 0; i < (sizeof(g_log_cmd) / sizeof(log_cmd_t)); i++) {
|
||||||
|
strcat(tmp_str, g_log_cmd[i].cmd);
|
||||||
|
if (i < (sizeof(g_log_cmd) / sizeof(log_cmd_t))-1) {
|
||||||
|
strcat(tmp_str, "|");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stdout, " %s %s\n", LOGGING_MODULE_NAME, tmp_str);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
fprintf(stdout, "1. usage of %s %s:\n", LOGGING_MODULE_NAME, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, " %s %s <level> [<module_name>]\n", LOGGING_MODULE_NAME, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, " %s %s off\n", LOGGING_MODULE_NAME, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, " %s %s get [<module_name>]\n", LOGGING_MODULE_NAME, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, " <level> = emerg | alert | crit | err | warn | notice | info | debug\n");
|
||||||
|
fprintf(stdout, " <module_name> the filtering module_name, only recode this module's log while set\n");
|
||||||
|
fprintf(stdout, " eg: %s %s info moudle1\n", LOGGING_MODULE_NAME, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, " %s %s off\n", LOGGING_MODULE_NAME, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, " %s %s get module1\n", LOGGING_MODULE_NAME, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
fprintf(stdout, "2. usage of %s %s is simple as %s\n", LOGGING_MODULE_NAME, g_log_cmd[1].cmd, g_log_cmd[0].cmd);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
fprintf(stdout, "3. usage of %s %s:\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, " %s %s add <ip_addr> [<port>] [<RFCfmt>]\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, " %s %s del <ip_addr> [<port>] [<RFCfmt>]\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, " %s %s get <ip_addr>\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, " %s %s getall\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, " <ip_addr> is the ip address of remote syslog server\n");
|
||||||
|
fprintf(stdout, " <port> is the port of remote syslog server\n");
|
||||||
|
fprintf(stdout, " <RFCfmt> = RFC3164fmt|RFC5424fmt, is the version of syslog format\n");
|
||||||
|
fprintf(stdout, " eg: %s %s add 192.168.100.1 514 RFC3164fmt\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, " %s %s del 192.168.100.1 514 RFC3164fmt\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, " %s %s get 192.168.100.1\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, " %s %s getall\n", LOGGING_MODULE_NAME, g_log_cmd[2].cmd);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
fprintf(stdout, "4. usage of %s %s:\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||||
|
fprintf(stdout, " %s %s <level>\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||||
|
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||||
|
fprintf(stdout, " <level> = emerg | alert | crit | err | warn | notice | info | debug \n");
|
||||||
|
fprintf(stdout, " eg: %s %s info\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||||
|
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[3].cmd);
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
|
fprintf(stdout, "5. usage of %s %s:\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||||
|
fprintf(stdout, " %s %s <level> [<file_path>] [<is_compress>] [<del_over_days>] [<del_over_size>]\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||||
|
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||||
|
fprintf(stdout, " <level> = emerg | alert | crit | err | warn | notice | info | debug\n");
|
||||||
|
fprintf(stdout, " <file_path> is the path of syslog files saved\n");
|
||||||
|
fprintf(stdout, " <is_compress> = 0 | 1 , which 0 is syslog files is not compress while 1 is compress\n");
|
||||||
|
fprintf(stdout, " <del_over_days> is the syslog files life-time (days)\n");
|
||||||
|
fprintf(stdout, " <del_over_size> is the syslog files life-size (bytes)\n");
|
||||||
|
fprintf(stdout, " eg: %s %s info /var/log/syslog-files 0 100 1024000\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||||
|
fprintf(stdout, " %s %s get\n", LOGGING_MODULE_NAME, g_log_cmd[4].cmd);
|
||||||
|
|
||||||
|
fprintf(stdout, "-----------------------------------------------------------------------------------------\n");
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stdout, "Parameter too few\n");
|
fprintf(stdout, "Parameter too few\n");
|
||||||
|
logging_usage();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[1], "-h")==0 || strcmp(argv[1], "--help")==0) {
|
||||||
|
logging_usage();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
g_log = ulog_init(LOGGING_MODULE_NAME, 1);
|
g_log = ulog_init(LOGGING_MODULE_NAME, 1);
|
||||||
if (g_log == NULL) {
|
if (g_log == NULL) {
|
||||||
|
|
Loading…
Reference in New Issue