* Minor cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35105 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-01-16 18:14:12 +00:00
parent 29ddbdbb53
commit c9025d9114
+19 -15
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2008, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2003-2010, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -29,16 +29,15 @@ static const char *kFacilities[] = {
}; };
static const int32 kNumFacilities = 24; static const int32 kNumFacilities = 24;
static int sLog = -1; static int sLog = -1;
static char sLastMessage[1024]; static char sLastMessage[1024];
static thread_id sLastThread; static thread_id sLastThread;
static int32 sRepeatCount; static int32 sRepeatCount;
static size_t sLogMaxSize = 524288; // 512kB static size_t sLogMaxSize = 524288; // 512kB
static bool sLogTimeStamps = false; static bool sLogTimeStamps = false;
/*! /*! Creates the log file if not yet existing, or renames the old
Creates the log file if not yet existing, or renames the old
log file, if it's too big already. log file, if it's too big already.
*/ */
static status_t static status_t
@@ -133,16 +132,21 @@ syslog_output(syslog_message &message)
int facility = SYSLOG_FACILITY_INDEX(message.priority); int facility = SYSLOG_FACILITY_INDEX(message.priority);
if (facility >= kNumFacilities) if (facility >= kNumFacilities)
facility = SYSLOG_FACILITY_INDEX(LOG_USER); facility = SYSLOG_FACILITY_INDEX(LOG_USER);
pos += snprintf(header + pos, sizeof(header) - pos, "%s", kFacilities[facility]); pos += snprintf(header + pos, sizeof(header) - pos, "%s",
kFacilities[facility]);
// add ident/thread ID // add ident/thread ID
if (message.ident[0] == '\0') { if (message.ident[0] == '\0') {
// ToDo: find out team name? // ToDo: find out team name?
} else } else {
pos += snprintf(header + pos, sizeof(header) - pos, " '%s'", message.ident); pos += snprintf(header + pos, sizeof(header) - pos, " '%s'",
message.ident);
}
if (message.options & LOG_PID) if ((message.options & LOG_PID) != 0) {
pos += snprintf(header + pos, sizeof(header) - pos, "[%ld]", message.from); pos += snprintf(header + pos, sizeof(header) - pos, "[%ld]",
message.from);
}
headerLength = pos + strlcpy(header + pos, ": ", sizeof(header) - pos); headerLength = pos + strlcpy(header + pos, ": ", sizeof(header) - pos);
if (headerLength >= (int32)sizeof(header)) if (headerLength >= (int32)sizeof(header))
@@ -175,7 +179,8 @@ syslog_output(syslog_message &message)
length = sizeof(buffer) - 1; length = sizeof(buffer) - 1;
if (message.from == sLastThread if (message.from == sLastThread
&& !strncmp(buffer + headerLength, sLastMessage, sizeof(sLastMessage))) { && !strncmp(buffer + headerLength, sLastMessage,
sizeof(sLastMessage))) {
// we got this message already // we got this message already
sRepeatCount++; sRepeatCount++;
} else { } else {
@@ -225,4 +230,3 @@ init_syslog_output(SyslogDaemon *daemon)
daemon->AddHandler(syslog_output); daemon->AddHandler(syslog_output);
} }