summaryrefslogtreecommitdiff
path: root/sysklogd
diff options
context:
space:
mode:
authorDenis Vlasenko2006-09-30 19:17:40 +0000
committerDenis Vlasenko2006-09-30 19:17:40 +0000
commit1decd0e5292181284e403cd9ecf7abf39a5d7363 (patch)
tree285bba5db4a019bfc00b2d51a3ebf43d225060e4 /sysklogd
parent39d551fd1570ca760582777b325ae3396d49ebf3 (diff)
downloadbusybox-1decd0e5292181284e403cd9ecf7abf39a5d7363.zip
busybox-1decd0e5292181284e403cd9ecf7abf39a5d7363.tar.gz
syslogd: add option to suppress logging of messages lower than level N (-n N)
Diffstat (limited to 'sysklogd')
-rw-r--r--sysklogd/syslogd.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 9a5a04a..a257e74 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -42,6 +42,9 @@ static int logFileRotate = 1;
/* interval between marks in seconds */
static int MarkInterval = 20 * 60;
+/* level of messages to be locally logged */
+static int logLevel = 8;
+
/* localhost's name */
static char LocalHostName[64];
@@ -413,10 +416,12 @@ retry:
#endif
{
/* now spew out the message to wherever it is supposed to go */
- if (opts & SYSLOG_OPT_small)
- message("%s %s\n", timestamp, msg);
- else
- message("%s %s %s %s\n", timestamp, LocalHostName, res, msg);
+ if (pri == 0 || LOG_PRI(pri) < logLevel) {
+ if (opts & SYSLOG_OPT_small)
+ message("%s %s\n", timestamp, msg);
+ else
+ message("%s %s %s %s\n", timestamp, LocalHostName, res, msg);
+ }
}
}
@@ -581,6 +586,13 @@ int syslogd_main(int argc, char **argv)
case 'O':
logFilePath = optarg;
break;
+ case 'l':
+ logLevel = atoi(optarg);
+ /* Valid levels are between 1 and 8 */
+ if (logLevel < 1 || logLevel > 8) {
+ bb_show_usage();
+ }
+ break;
#ifdef CONFIG_FEATURE_ROTATE_LOGFILE
case 's':
logFileSize = atoi(optarg) * 1024;