30#include <QtCore/QString>
32#include <core/config.h>
62 static Logger*
bootstrap(
unsigned msk,
const QString& sLogFilePath = QString(),
bool bUseStdout =
true );
121 void log(
unsigned level,
const QString& class_name,
const char* func_name,
const QString& msg );
170 Logger(
const QString& sLogFilePath = QString(),
bool bUseStdout =
true );
179 static int hextoi(
const char* str,
long len );
Helper class to preserve and restore recursive crash context strings using an RAAI pattern.
CrashContext(QString *pContext)
Class for writing logs to the console.
static Logger * create_instance(const QString &sLogFilePath=QString(), bool bUseStdout=true)
If __instance equals 0, a new H2Core::Logger singleton will be created and stored in it.
pthread_cond_t __messages_available
bool __use_file
write log to file if set to true
void log(unsigned level, const QString &class_name, const char *func_name, const QString &msg)
the log function
static QString * getCrashContext()
std::list< QString > queue_t
message queue type
pthread_mutex_t __mutex
lock for adding or removing elements only
void flush() const
Waits till the logger thread poped all remaining messages from __msg_queue.
bool __running
set to true when the logger thread is running
void set_use_file(bool use)
set use file flag
static Logger * __instance
Object holding the current H2Core::Logger singleton.
Logger(const QString &sLogFilePath=QString(), bool bUseStdout=true)
constructor
bool use_file() const
return __use_file
static int hextoi(const char *str, long len)
convert an hex string to an integer.
static unsigned bit_mask()
return the current log level bit mask
static Logger * bootstrap(unsigned msk, const QString &sLogFilePath=QString(), bool bUseStdout=true)
create the logger instance if not exists, set the log level and return the instance
queue_t __msg_queue
the message queue
static thread_local QString * pCrashContext
static const char * __levels[]
levels strings
bool should_log(unsigned lvl) const
return true if the level is set in the bitmask
static Logger * get_instance()
Returns a pointer to the current H2Core::Logger singleton stored in __instance.
static void set_bit_mask(unsigned msk)
set the bitmask
static unsigned parse_log_level(const char *lvl)
parse a log level string and return the corresponding bit mask
static void setCrashContext(QString *pContext)
static unsigned __bit_msk
the bitmask of log_level_t
friend void * loggerThread_func(void *param)
needed for being able to access logger internal
log_levels
possible logging bits