/*
-Copyright (c) 2004-2007, John Hurst
+Copyright (c) 2004-2009, John Hurst
All rights reserved.
Redistribution and use in source and binary forms, with or without
#include <KM_util.h>
#include <stdarg.h>
#include <errno.h>
+#include <iosfwd>
#define LOG_MSG_IMPL(t) \
va_list args; \
const i32_t LOG_ALLOW_NONE = 0x00000000;
const i32_t LOG_ALLOW_ALL = 0x000fffff;
- // options are used to control display format
- // default is 0 (
+ // options are used to control display format default is 0.
const i32_t LOG_OPTION_TYPE = 0x01000000;
const i32_t LOG_OPTION_TIMESTAMP = 0x02000000;
const i32_t LOG_OPTION_PID = 0x04000000;
bool Unarchive(MemIOReader* Reader);
};
+ //
+ std::basic_ostream<char, std::char_traits<char> >&
+ operator<<(std::basic_ostream<char, std::char_traits<char> >& strm, LogEntry const& Entry);
+
- typedef ArchivableList<LogEntry> LogEntryList_t;
+ typedef ArchivableList<LogEntry> LogEntryList;
//
class ILogSink
class EntryListLogSink : public ILogSink
{
Mutex m_Lock;
- LogEntryList_t& m_Target;
+ LogEntryList& m_Target;
KM_NO_COPY_CONSTRUCT(EntryListLogSink);
EntryListLogSink();
public:
- EntryListLogSink(LogEntryList_t& target) : m_Target(target) {}
+ EntryListLogSink(LogEntryList& target) : m_Target(target) {}
virtual ~EntryListLogSink() {}
void WriteEntry(const LogEntry& Entry);
void WriteEntry(const LogEntry&);
};
+
+ // write messages to the syslog facility
+ class SyslogLogSink : public ILogSink
+ {
+ Mutex m_Lock;
+ KM_NO_COPY_CONSTRUCT(SyslogLogSink);
+ SyslogLogSink();
+
+ public:
+ SyslogLogSink(const std::string& source_name, int facility);
+ virtual ~SyslogLogSink();
+ void WriteEntry(const LogEntry&);
+ };
+
+ // convert a string into the appropriate syslog facility id
+ int SyslogNameToFacility(const std::string& facility_name);
+
#endif