|
hydrogen 1.1.1
|
Class for writing logs to the console. More...
#include <Logger.h>
Public Types | |
| enum | log_levels { None = 0x00 , Error = 0x01 , Warning = 0x02 , Info = 0x04 , Debug = 0x08 , Constructors = 0x10 , AELockTracing = 0x20 } |
| possible logging bits More... | |
| typedef std::list< QString > | queue_t |
| message queue type More... | |
Public Member Functions | |
| ~Logger () | |
| destructor More... | |
| bool | should_log (unsigned lvl) const |
| return true if the level is set in the bitmask More... | |
| void | set_use_file (bool use) |
| set use file flag More... | |
| bool | use_file () const |
| return __use_file More... | |
| void | log (unsigned level, const QString &class_name, const char *func_name, const QString &msg) |
| the log function More... | |
Static Public Member Functions | |
| static Logger * | bootstrap (unsigned msk) |
| create the logger instance if not exists, set the log level and return the instance More... | |
| static Logger * | create_instance () |
| If __instance equals 0, a new H2Core::Logger singleton will be created and stored in it. More... | |
| static Logger * | get_instance () |
| Returns a pointer to the current H2Core::Logger singleton stored in __instance. More... | |
| static void | set_bit_mask (unsigned msk) |
| set the bitmask More... | |
| static unsigned | bit_mask () |
| return the current log level bit mask More... | |
| static unsigned | parse_log_level (const char *lvl) |
| parse a log level string and return the corresponding bit mask More... | |
Private Member Functions | |
| Logger () | |
| constructor More... | |
Static Private Member Functions | |
| static int | hextoi (const char *str, long len) |
| convert an hex string to an integer. More... | |
Private Attributes | |
| bool | __use_file |
| write log to file if set to true More... | |
| bool | __running |
| set to true when the logger thread is running More... | |
| pthread_mutex_t | __mutex |
| lock for adding or removing elements only More... | |
| queue_t | __msg_queue |
| the message queue More... | |
| pthread_cond_t | __messages_available |
Static Private Attributes | |
| static Logger * | __instance =nullptr |
| Object holding the current H2Core::Logger singleton. More... | |
| static unsigned | __bit_msk = 0 |
| the bitmask of log_level_t More... | |
| static const char * | __levels [] = { "None", "Error", "Warning", "Info", "Debug" } |
| levels strings More... | |
Friends | |
| void * | loggerThread_func (void *param) |
| needed for being able to access logger internal More... | |
Class for writing logs to the console.
| typedef std::list<QString> queue_t |
message queue type
| enum log_levels |
possible logging bits
| Enumerator | |
|---|---|
| None | |
| Error | |
| Warning | |
| Info | |
| Debug | |
| Constructors | |
| AELockTracing | Intended to be used log the locking of the AudioEngine. But this feature isn't implemented yet. |
| ~Logger | ( | ) |
destructor
|
private |
constructor
|
inlinestatic |
return the current log level bit mask
|
static |
create the logger instance if not exists, set the log level and return the instance
| msk | the logging level bitmask |
|
static |
If __instance equals 0, a new H2Core::Logger singleton will be created and stored in it.
It is called in Hydrogen::create_instance().
|
inlinestatic |
Returns a pointer to the current H2Core::Logger singleton stored in __instance.
|
staticprivate |
convert an hex string to an integer.
returns -1 on failure.
| str | the hex string to convert |
| len | the length of the string |
| void log | ( | unsigned | level, |
| const QString & | class_name, | ||
| const char * | func_name, | ||
| const QString & | msg | ||
| ) |
the log function
| level | used to output the corresponding level string |
| class_name | the name of the calling class |
| func_name | the name of the calling function/method |
| msg | the message to log |
|
static |
parse a log level string and return the corresponding bit mask
| lvl | the log level string |
|
inlinestatic |
set the bitmask
| msk | the new bitmask to set |
|
inline |
set use file flag
| use | the flag status |
|
inline |
return true if the level is set in the bitmask
| lvl | the level to check |
|
inline |
return __use_file
|
friend |
needed for being able to access logger internal
| param | is a pointer to the logger instance |
|
staticprivate |
the bitmask of log_level_t
|
staticprivate |
Object holding the current H2Core::Logger singleton.
It is initialized with NULL, set with create_instance(), and accessed with get_instance().
levels strings
|
private |
|
private |
the message queue
|
private |
lock for adding or removing elements only
|
private |
set to true when the logger thread is running
|
private |
write log to file if set to true