36#include "blocxx/BLOCXX_config.h"
46#if defined(BLOCXX_WIN32)
47#define snprintf _snprintf
58 static char log_ident[NAME_MAX];
60 static char log_ident[255];
65 const char *
const name;
69 static struct Facilities facilities[] =
75 {
"authpriv", LOG_AUTHPRIV },
81 {
"daemon", LOG_DAEMON },
102 {
"uucp", LOG_UUCP },
105 {
"local0", LOG_LOCAL0 },
108 {
"local1", LOG_LOCAL1 },
111 {
"local2", LOG_LOCAL2 },
114 {
"local3", LOG_LOCAL3 },
117 {
"local4", LOG_LOCAL4 },
120 {
"local5", LOG_LOCAL5 },
123 {
"local6", LOG_LOCAL6 },
126 {
"local7", LOG_LOCAL7 },
144 BLOCXX_THROW(LoggerException,
145 "SyslogAppender: Empty syslog identity name"
148 if( facility.
empty())
150 BLOCXX_THROW(LoggerException,
151 "SyslogAppender: Empty syslog facility name"
155 struct Facilities *f = facilities;
156 for( ; f->name != NULL; f++)
158 if( facility.equals(f->name))
163 BLOCXX_THROW(LoggerException,
164 Format(
"SyslogAppender: Unknown syslog facility name: %1",
176 ::snprintf( log_ident,
sizeof(log_ident),
"%s", identity.
c_str());
177 openlog( log_ident, LOG_CONS, f->code);
192 syslogPriority = LOG_CRIT;
196 syslogPriority = LOG_ERR;
200 syslogPriority = LOG_WARNING;
204 syslogPriority = LOG_INFO;
210 syslogPriority = LOG_DEBUG;
214 syslogPriority = LOG_INFO;
219 for (
size_t i = 0; i < a.
size(); ++i)
221 char format[] =
"%s";
222 syslog( syslogPriority, format, a[i].c_str() );
#define BLOCXX_GLOBAL_MUTEX_INIT()
#define BLOCXX_GLOBAL_STRING_INIT(str)
LogAppender(const StringArray &components=ALL_COMPONENTS, const StringArray &categories=ALL_CATEGORIES, const String &pattern=STR_TTCC_MESSAGE_FORMAT)
static const GlobalString STR_DEBUG2_CATEGORY
static const GlobalString STR_WARNING_CATEGORY
static const GlobalString STR_DEBUG3_CATEGORY
static const GlobalString STR_DEBUG_CATEGORY
static const GlobalString STR_FATAL_CATEGORY
static const GlobalString STR_ERROR_CATEGORY
static const GlobalString STR_INFO_CATEGORY
This String class is an abstract data type that represents as NULL terminated string of characters.
bool equalsIgnoreCase(const String &arg) const
Determine if another String object is equal to this String object, ignoring case in the comparision.
const char * c_str() const
StringArray tokenize(const char *delims=" \n\r\t\v", EReturnDelimitersFlag returnDelimitersAsTokens=E_DISCARD_DELIMITERS, EEmptyTokenReturnFlag returnEmptyTokens=E_SKIP_EMPTY_TOKENS) const
Tokenize this String object using the given delimeters.
virtual ~SyslogAppender()
SyslogAppender(const StringArray &components, const StringArray &categories, const String &pattern, const String &identity, const String &facility)
static bool calledOpenLog
static const GlobalString STR_DEFAULT_MESSAGE_PATTERN
virtual void doProcessLogMessage(const String &formattedMessage, const LogMessage &message) const
LazyGlobal< String, char const *const > GlobalString
Array< String > StringArray
LazyGlobal< Mutex, int, GlobalMutexFactory > GlobalMutex