30#include <QtCore/QString>
33#include <core/config.h>
62 const QString& sLogFilePath = QString(),
63 bool bUseStdout =
true,
64 bool bLogTimestamps =
false,
65 bool bLogColors =
true );
73 bool bUseStdout =
true,
74 bool bLogTimestamps =
false,
75 bool bLogColors =
true );
128 void log(
unsigned level,
const QString& sClassName,
129 const char* func_name,
const QString& sMsg,
130 const QString& sColor =
"" );
187 Logger(
const QString& sLogFilePath = QString(),
bool bUseStdout =
true,
188 bool bLogTimestamps =
false,
bool bLogColors =
true );
197 static int hextoi(
const char* str,
long len );
CrashContext(QString *pContext)
static Logger * create_instance(const QString &sLogFilePath=QString(), bool bUseStdout=true, bool bLogTimestamps=false, bool bLogColors=true)
If __instance equals 0, a new H2Core::Logger singleton will be created and stored in it.
bool getLogColors() const
pthread_cond_t __messages_available
static QString * getCrashContext()
std::list< QString > queue_t
message queue type
static Logger * bootstrap(unsigned msk, const QString &sLogFilePath=QString(), bool bUseStdout=true, bool bLogTimestamps=false, bool bLogColors=true)
create the logger instance if not exists, set the log level and return the instance
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.
Logger(const QString &sLogFilePath=QString(), bool bUseStdout=true, bool bLogTimestamps=false, bool bLogColors=true)
constructor
bool __running
set to true when the logger thread is running
static Logger * __instance
Object holding the current H2Core::Logger singleton.
static bool isAvailable()
Checks whether the Logger instances was already created and can be used by other parts of Hydrogen.
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
queue_t __msg_queue
the message queue
static thread_local QString * pCrashContext
static const char * __levels[]
levels strings
void log(unsigned level, const QString &sClassName, const char *func_name, const QString &sMsg, const QString &sColor="")
the log function
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