svn commit: trunk/busybox: include sysklogd
vda at busybox.net
vda at busybox.net
Sat Sep 30 19:17:41 UTC 2006
Author: vda
Date: 2006-09-30 12:17:40 -0700 (Sat, 30 Sep 2006)
New Revision: 16272
Log:
syslogd: add option to suppress logging of messages lower than level N (-n N)
Modified:
trunk/busybox/include/usage.h
trunk/busybox/sysklogd/syslogd.c
Changeset:
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h 2006-09-30 16:28:30 UTC (rev 16271)
+++ trunk/busybox/include/usage.h 2006-09-30 19:17:40 UTC (rev 16272)
@@ -2780,7 +2780,8 @@
"\t-m MIN\t\tMinutes between MARK lines (default=20, 0=off)\n" \
"\t-n\t\tRun as a foreground process\n" \
"\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" \
- "\t-S\t\tMake logging output smaller." \
+ "\t-l n\tSets the local log level of messages to n\n" \
+ "\t-S\t\tMake logging output smaller" \
USE_FEATURE_ROTATE_LOGFILE( \
"\n\t-s SIZE\t\tMax size (KB) before rotate (default=200KB, 0=off)\n" \
"\t-b NUM\t\tNumber of rotated logs to keep (default=1, max=99, 0=purge)") \
Modified: trunk/busybox/sysklogd/syslogd.c
===================================================================
--- trunk/busybox/sysklogd/syslogd.c 2006-09-30 16:28:30 UTC (rev 16271)
+++ trunk/busybox/sysklogd/syslogd.c 2006-09-30 19:17:40 UTC (rev 16272)
@@ -42,6 +42,9 @@
/* 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 @@
#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 @@
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;
More information about the busybox-cvs
mailing list