Add 'notice' severity to *Logger.

Refs #6070
This commit is contained in:
Michael Friedrich 2014-05-22 12:12:15 +02:00
parent ff80ed1c38
commit 7462c8320a
6 changed files with 20 additions and 5 deletions

View File

@ -233,7 +233,7 @@ string(value) | Converts the value to a string.
number(value) | Converts the value to a number.
bool(value) | Converts the value to a bool.
log(value) | Writes a message to the log. Non-string values are converted to a JSON string.
log(severity, facility, value) | Writes a message to the log. `severity` can be one of `LogDebug`, `LogInformation`, `LogWarning` and `LogCritical`. Non-string values are converted to a JSON string.
log(severity, facility, value) | Writes a message to the log. `severity` can be one of `LogDebug`, `LogNotice`, `LogInformation`, `LogWarning` and `LogCritical`. Non-string values are converted to a JSON string.
exit(integer) | Terminates the application.
### <a id="operators"></a> Dictionary Operators
@ -1494,7 +1494,7 @@ Attributes:
Name |Description
----------------|----------------
path |**Required.** The log path.
severity |**Optional.** The minimum severity for this log. Can be "debug", "information", "warning" or "critical". Defaults to "information".
severity |**Optional.** The minimum severity for this log. Can be "debug", "notice", "information", "warning" or "critical". Defaults to "information".
### <a id="objecttype-sysloglogger"></a> SyslogLogger
@ -1511,7 +1511,7 @@ Attributes:
Name |Description
----------------|----------------
severity |**Optional.** The minimum severity for this log. Can be "debug", "information", "warning" or "critical". Defaults to "warning".
severity |**Optional.** The minimum severity for this log. Can be "debug", "notice", "information", "notice", "warning" or "critical". Defaults to "warning".

View File

@ -40,6 +40,7 @@ bool Logger::m_ConsoleLogEnabled = true;
void Logger::StaticInitialize(void)
{
ScriptVariable::Set("LogDebug", LogDebug, true, true);
ScriptVariable::Set("LogNotice", LogNotice, true, true);
ScriptVariable::Set("LogInformation", LogInformation, true, true);
ScriptVariable::Set("LogWarning", LogWarning, true, true);
ScriptVariable::Set("LogCritical", LogCritical, true, true);
@ -142,6 +143,8 @@ String Logger::SeverityToString(LogSeverity severity)
switch (severity) {
case LogDebug:
return "debug";
case LogNotice:
return "notice";
case LogInformation:
return "information";
case LogWarning:
@ -162,6 +165,8 @@ LogSeverity Logger::StringToSeverity(const String& severity)
{
if (severity == "debug")
return LogDebug;
else if (severity == "notice")
return LogNotice;
else if (severity == "information")
return LogInformation;
else if (severity == "warning")

View File

@ -34,6 +34,7 @@ namespace icinga
enum LogSeverity
{
LogDebug,
LogNotice,
LogInformation,
LogWarning,
LogCritical

View File

@ -97,6 +97,12 @@ void StreamLogger::ProcessLogEntry(std::ostream& stream, bool tty, const LogEntr
if (tty) {
switch (entry.Severity) {
case LogNotice:
stream << "\x1b[1;34m"; // blue
break;
case LogInformation:
stream << "\x1b[1;32m"; // green
break;
case LogWarning:
stream << "\x1b[1;33m"; // yellow;
break;

View File

@ -53,6 +53,9 @@ void SyslogLogger::ProcessLogEntry(const LogEntry& entry)
case LogDebug:
severity = LOG_DEBUG;
break;
case LogNotice:
severity = LOG_NOTICE;
break;
case LogWarning:
severity = LOG_WARNING;
break;

View File

@ -191,7 +191,7 @@ void ApiClient::KeepAliveTimerHandler(void)
BOOST_FOREACH(const ApiClient::Ptr& client, endpoint->GetClients()) {
if (client->m_Seen < timeout) {
Log(LogInformation, "remote", "Closing connection with inactive endpoint '" + endpoint->GetName() + "'");
Log(LogNotice, "remote", "Closing connection with inactive endpoint '" + endpoint->GetName() + "'");
client->Disconnect();
}
}
@ -205,7 +205,7 @@ void ApiClient::KeepAliveTimerHandler(void)
BOOST_FOREACH(const ApiClient::Ptr& client, listener->GetAnonymousClients()) {
if (client->m_Seen < timeout) {
Log(LogInformation, "remote", "Closing connection with inactive anonymous endpoint '" + client->GetIdentity() + "'");
Log(LogNotice, "remote", "Closing connection with inactive anonymous endpoint '" + client->GetIdentity() + "'");
client->Disconnect();
}
}