28#if !defined(TARGET_OS_MAC)
29#define LOG_ENABLE_THREAD_SETTING
114 const char* methodName);
128 const char* mMethodName;
158 const char* methodName,
178 const char * logFileName = 0,
180 const Data& syslogFacility =
"LOG_DAEMON",
182 const Data& instanceName =
"");
186 const char * logFileName = 0,
188 const Data& syslogFacility =
"LOG_DAEMON",
189 const Data& messageStructure =
"Unstructured",
190 const Data& instanceName =
"");
194 const char * logFileName = 0,
196 const char* syslogFacility =
"LOG_DAEMON",
197 const char* messageStructure =
"Unstructured",
198 const char* instanceName =
"");
203 const Data& syslogFacility =
"LOG_DAEMON",
205 const Data& instanceName =
"");
248 const char * logFileName = NULL,
259 const char * logFileName = NULL,
280 static std::ostream&
Instance(
unsigned int bytesToWrite);
301 const char *logFileName=NULL,
304 const Data& instanceName =
"")
326 const char* logFileName = NULL,
329 const Data& instanceName =
"");
339 std::ostream&
Instance(
unsigned int bytesToWrite);
390 const char * logFileName = NULL,
401 const char * logFileName = NULL,
430 friend void ::freeLocalLogger(
void* pThreadData);
437#ifdef LOG_ENABLE_THREAD_SETTING
458 const Data& messageWithHeaders,
459 const Data& instanceName) = 0;
477 TlsDestructorInitializer tlsDestructorInitializer;
Wraps your platform's implementation of hash_map, hash_multimap, and hash_set.
void freeLocalLogger(void *pThreadData)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Interface functor for external logging.
virtual bool operator()(Log::Level level, const Subsystem &subsystem, const Data &appName, const char *file, int line, const Data &message, const Data &messageWithHeaders, const Data &instanceName)=0
return true to also do default logging, false to suppress default logging.
virtual ~ExternalLogger()
Class to initialize Log class static variables.
static unsigned int mInstanceCounter
Implementation for logging macros.
EncodeStream & asStream()
Thread Local logger settings storage.
int reinitialize(LocalLoggerId loggerId, Type type, Level level, const char *logFileName=NULL, ExternalLogger *externalLogger=NULL, MessageStructure messageStructure=Unstructured)
Reinitialize all new setting for a local logger instance.
int remove(LocalLoggerId loggerId)
Remove existing logger instance from map and destroy.
Mutex mLoggerInstancesMapMutex
Mutex to synchronize access to Thread Local logger settings storage.
LocalLoggerId create(Type type, Level level, const char *logFileName=NULL, ExternalLogger *externalLogger=NULL, MessageStructure messageStructure=Unstructured)
Create new logger instance and return its ID (zero on error)
HashMap< LocalLoggerId, std::pair< ThreadData *, int > > LoggerInstanceMap
Storage for Thread Local loggers and their use-counts.
LocalLoggerId mLastLocalLoggerId
Last used LocalLoggerId.
void decreaseUseCount(LocalLoggerId loggerId)
Decrease use counter for given loggerId.
LoggerInstanceMap mLoggerInstancesMap
ThreadData * getData(LocalLoggerId loggerId)
Get pointer to ThreadData for given ID and increase use counter.
volatile MessageStructure mMessageStructure
ExternalLogger * mExternalLogger
unsigned int maxByteCount()
std::ostream & Instance(unsigned int bytesToWrite)
Return logger stream instance, creating it if needed.
void droppingPrivileges(uid_t uid, pid_t pid)
void setKeepAllLogFiles(bool keepAllLogFiles)
volatile unsigned int mMaxByteCount
void reset()
Frees logger stream.
volatile bool mKeepAllLogFiles
volatile unsigned int mMaxLineCount
volatile bool mKeepAllLogFilesSet
ThreadData(LocalLoggerId id, Type type=Cout, Level level=Info, const char *logFileName=NULL, ExternalLogger *pExternalLogger=NULL, MessageStructure messageStructure=Unstructured, const Data &instanceName="")
unsigned int maxLineCount()
ThreadSetting(int serv, Level level)
Singleton that handles logging calls.
static bool isLogging(Log::Level level, const Subsystem &)
static const int mSyslogPriority[]
static HashMap< ThreadIf::Id, std::pair< ThreadSetting, bool > > mThreadToLevel
DEPRECATED! Left for backward compatibility - use localLoggers instead.
static ExternalLogger * getExternal()
static ThreadData & getLoggerData()
static void setMaxByteCount(unsigned int maxByteCount)
@ OnlyExternal
log messages are only written to external logger
@ VSDebugWindow
Use only for Visual Studio Debug Window logging - WIN32 must be defined.
@ OnlyExternalNoHeaders
same as OnlyExternal, only the messageWithHeaders param of the ExternalLogger will be empty.
static const char mCEEPri[][32]
static Data mInstanceName
static int mSyslogFacility
static const ThreadSetting * getThreadSetting()
DEPRECATED! Left for backward compatibility - use localLoggers instead.
static ThreadData mDefaultLoggerData
Default logger settings.
static int parseSyslogFacilityName(const Data &facilityName)
static void reset()
Frees logger stream.
static Data toString(Level l)
static Level getServiceLevel(int service)
static unsigned int MaxLineCount
static void setServiceLevel(int service, Level l)
DEPRECATED! Left for backward compatibility - use localLoggers instead.
static int setThreadLocalLogger(LocalLoggerId loggerId)
Set logger instance with given ID as a thread local logger.
static LocalLoggerMap mLocalLoggerMap
int LocalLoggerId
Thread Local logger ID type.
static std::atomic< unsigned int > touchCount
static Level toLevel(const Data &l)
static HashMap< int, Level > mServiceToLevel
DEPRECATED! Left for backward compatibility - use localLoggers instead.
static void setThreadSetting(ThreadSetting info)
static ThreadIf::TlsKey * mLocalLoggerKey
static void setLevel(Level level)
Set logging level for current thread.
static int localLoggerReinitialize(LocalLoggerId loggerId, Type type, Level level, const char *logFileName=NULL, ExternalLogger *externalLogger=NULL, MessageStructure messageStructure=Unstructured)
Reinitialize all new setting for a local logger instance.
static unsigned int MaxByteCount
static EncodeStream & tags(Log::Level level, const Subsystem &subsystem, const char *file, int line, const char *methodName, EncodeStream &strm, MessageStructure messageStructure)
output the loglevel, hostname, appname, pid, tid, subsystem
static HashMap< int, std::set< ThreadIf::Id > > mServiceToThreads
static int localLoggerRemove(LocalLoggerId loggerId)
Destroy existing logger instance.
static Level level()
Return logging level for current thread.
static void setKeepAllLogFiles(bool keepAllLogFiles)
static void setMaxLineCount(unsigned int maxLineCount)
static LocalLoggerId id()
static void droppingPrivileges(uid_t uid, pid_t pid)
static bool KeepAllLogFiles
static const char mDescriptions[][32]
static void initialize(Type type, Level level, const Data &appName, const char *logFileName=0, ExternalLogger *externalLogger=0, const Data &syslogFacility="LOG_DAEMON", MessageStructure messageStructure=Unstructured, const Data &instanceName="")
static void OutputToWin32DebugWindow(const Data &result)
static Type toType(const Data &t)
static ThreadIf::TlsKey * mLevelKey
static std::ostream & Instance(unsigned int bytesToWrite)
static LocalLoggerId localLoggerCreate(Type type, Level level, const char *logFileName=NULL, ExternalLogger *externalLogger=NULL, MessageStructure messageStructure=Unstructured)
Create new logger instance and return its ID (zero on error)
Class used to specify what sub-system given sections of code belong to, for use by the logging system...
static void * tlsGetValue(TlsKey key)
This function follows pthread_getspecific() signature.
An ostream that operates on an existing Data.
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
static LogStaticInitializer _staticLogInit
std::unique_lock< Mutex > Lock
A convenience class to lock a Lockable (such as a Mutex) on object creation, and unlock on destructio...