diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-30 19:17:40 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-30 19:17:40 +0000 |
commit | 1decd0e5292181284e403cd9ecf7abf39a5d7363 (patch) | |
tree | 285bba5db4a019bfc00b2d51a3ebf43d225060e4 | |
parent | 39d551fd1570ca760582777b325ae3396d49ebf3 (diff) | |
download | busybox-w32-1decd0e5292181284e403cd9ecf7abf39a5d7363.tar.gz busybox-w32-1decd0e5292181284e403cd9ecf7abf39a5d7363.tar.bz2 busybox-w32-1decd0e5292181284e403cd9ecf7abf39a5d7363.zip |
syslogd: add option to suppress logging of messages lower than level N (-n N)
-rw-r--r-- | include/usage.h | 3 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 20 |
2 files changed, 18 insertions, 5 deletions
diff --git a/include/usage.h b/include/usage.h index 543befca3..1da436ad4 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -2780,7 +2780,8 @@ USE_FEATURE_START_STOP_DAEMON_FANCY( \ | |||
2780 | "\t-m MIN\t\tMinutes between MARK lines (default=20, 0=off)\n" \ | 2780 | "\t-m MIN\t\tMinutes between MARK lines (default=20, 0=off)\n" \ |
2781 | "\t-n\t\tRun as a foreground process\n" \ | 2781 | "\t-n\t\tRun as a foreground process\n" \ |
2782 | "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" \ | 2782 | "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" \ |
2783 | "\t-S\t\tMake logging output smaller." \ | 2783 | "\t-l n\tSets the local log level of messages to n\n" \ |
2784 | "\t-S\t\tMake logging output smaller" \ | ||
2784 | USE_FEATURE_ROTATE_LOGFILE( \ | 2785 | USE_FEATURE_ROTATE_LOGFILE( \ |
2785 | "\n\t-s SIZE\t\tMax size (KB) before rotate (default=200KB, 0=off)\n" \ | 2786 | "\n\t-s SIZE\t\tMax size (KB) before rotate (default=200KB, 0=off)\n" \ |
2786 | "\t-b NUM\t\tNumber of rotated logs to keep (default=1, max=99, 0=purge)") \ | 2787 | "\t-b NUM\t\tNumber of rotated logs to keep (default=1, max=99, 0=purge)") \ |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 9a5a04adb..a257e740e 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -42,6 +42,9 @@ static int logFileRotate = 1; | |||
42 | /* interval between marks in seconds */ | 42 | /* interval between marks in seconds */ |
43 | static int MarkInterval = 20 * 60; | 43 | static int MarkInterval = 20 * 60; |
44 | 44 | ||
45 | /* level of messages to be locally logged */ | ||
46 | static int logLevel = 8; | ||
47 | |||
45 | /* localhost's name */ | 48 | /* localhost's name */ |
46 | static char LocalHostName[64]; | 49 | static char LocalHostName[64]; |
47 | 50 | ||
@@ -413,10 +416,12 @@ retry: | |||
413 | #endif | 416 | #endif |
414 | { | 417 | { |
415 | /* now spew out the message to wherever it is supposed to go */ | 418 | /* now spew out the message to wherever it is supposed to go */ |
416 | if (opts & SYSLOG_OPT_small) | 419 | if (pri == 0 || LOG_PRI(pri) < logLevel) { |
417 | message("%s %s\n", timestamp, msg); | 420 | if (opts & SYSLOG_OPT_small) |
418 | else | 421 | message("%s %s\n", timestamp, msg); |
419 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); | 422 | else |
423 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); | ||
424 | } | ||
420 | } | 425 | } |
421 | } | 426 | } |
422 | 427 | ||
@@ -581,6 +586,13 @@ int syslogd_main(int argc, char **argv) | |||
581 | case 'O': | 586 | case 'O': |
582 | logFilePath = optarg; | 587 | logFilePath = optarg; |
583 | break; | 588 | break; |
589 | case 'l': | ||
590 | logLevel = atoi(optarg); | ||
591 | /* Valid levels are between 1 and 8 */ | ||
592 | if (logLevel < 1 || logLevel > 8) { | ||
593 | bb_show_usage(); | ||
594 | } | ||
595 | break; | ||
584 | #ifdef CONFIG_FEATURE_ROTATE_LOGFILE | 596 | #ifdef CONFIG_FEATURE_ROTATE_LOGFILE |
585 | case 's': | 597 | case 's': |
586 | logFileSize = atoi(optarg) * 1024; | 598 | logFileSize = atoi(optarg) * 1024; |