#include <Log.h>
Public Types | |
| typedef unsigned int | PreambleFlags |
Public Member Functions | |
| GlobalLog (const wstring &programName, Mutex::GlobalData &globalData, size_t maxLineLength) | |
| ~GlobalLog () | |
| void | registerPattern (const wstring &pattern) |
| void | unregisterPattern (const wstring &pattern) |
| void | clearPatterns () |
| const vector< wstring > & | patterns () const |
| LogLevel | level () const |
| void | setLevel (const LogLevel level) |
| LogLevel | threshold () const |
| void | setThreshold (const LogLevel threshold) |
| void | setPreambleFlags (const PreambleFlags preambleFlags) |
| void | lock () |
| void | unlock () |
| bool | isEnabled (const LogLevel level) |
| bool | isEnabled (const wstring &category) |
| const wstring | levelName (const LogLevel level) const |
| Return the name of the specified log level. | |
| const wstring | levelColor (const LogLevel level) const |
| Return the color string for the specified log level. | |
| void | write (const wstring &category, const LogLevel level, wostringstream &wos) |
| void | setIndentationState (const bool useIndentation) |
| Enable or disable the indentation mechanism. | |
| void | setIndentationAmount (const size_t spaces) |
| void | registerIndentationLevelPlaceholder (int &indentationLevel) |
| void | unregisterIndentationLevelPlaceholder () |
| const int & | indentationLevelPlaceholder () const |
| bool | outputToTTY () const |
Protected Member Functions | |
| const wstring | preamble (const wstring &category, const LogLevel level) |
| void | splitLine (const wstring &line, vector< wstring > &lines, wstring::size_type reserved) |
| void | splitMultiLine (const wstring &line, vector< wstring > &lines) |
| const wstring | indent (const int threadId) const |
| const int | indentationLevel (const int threadId) const |
| const wstring | fit (const wstring &text, const size_t limit) |
Protected Attributes | |
| wstring | m_programName |
| argv[0]. | |
| LogLevel | m_level |
| The current log level. | |
| LogLevel | m_threshold |
| The threshold below which messages are allowed unconditionally. | |
| vector< wstring > | m_patterns |
| vector< pair< wstring, wstring > > | m_levelInfo |
| A vector of strings containing the names of all the levels. | |
| PreambleFlags | m_preambleFlags |
| size_t | m_maxLineLength |
| bool | m_useIndentation |
| `true' if the indentation mechanism is enabled. | |
| size_t | m_spaces |
| The number of spaces per indentation level. | |
| size_t | m_maxLogLevelNameLength |
| The length of the longest level name. | |
| hash_map< int, int * > | m_indentationLevels |
| bool | m_useColors |
| `true' if the logging should use colors on ANSI terminals. | |
| Mutex::GlobalData & | m_globalData |
| Mutex | m_mutex |
|
||||||||||||||||
|
Create a log object that can be shared among threads. When the log object is first created, it won't have any logging levels defined or patterns enabled and until that happens, no logging will be possible (outside of the Log object itself).
|
|
|
Destroy the log object, releasing its mutex if held in the current thread. |
|
|
Clear the pattern list. Note that the pattern matching the category used by the log object itself is re-added. |
|
||||||||||||
|
Make a string fit into a certain number of characters. If the string is too short, pad it with spaces (in front). If it's too long, cut the excess + 3 characters, and replace the first 3 characters with "...".
|
|
|
Return a string containing a number of spaces reflecting the indentation level in the given thread.
|
|
|
Return the indentation level of the given thread, or -1 if a placeholder hasn't been set for it.
|
|
|
Get the indentation level placeholder or 0 if not set.
|
|
|
Check whether a certain category is allowed to log messages, by matching it against registered patterns.
|
|
|
Check that logging is allowed on a given level.
|
|
|
Return the current logging level. Logging happens only if the logging level is less than or equal to the value returned by this function.
|
|
|
Lock the log, guaranteeing the current thread exclusive access. This call can block if the log is already locked. |
|
|
Check whether or not output goes to a terminal.
|
|
|
Return a vector containing all registered patterns.
|
|
||||||||||||
|
Prepare a string to be inserted at the beginning of every line in the log. The string can be customized via the `setPreambleFlags()' method.
|
|
|
Establish a placeholder for the thread's current indentation level. The log object will use the value of the integer at that location to properly indent the messages logged. It is the thread's responsability to properly update it.
|
|
|
Turn on logging for categories matching a certain pattern.
|
|
|
Set the number of spaces per indentation level. This applies to all threads for now.
|
|
|
Set the logging level. Logging happens only if the logging level is less than or equal to the value set with this function.
|
|
|
Set the preamble flags, determining how to make up the preamble.
|
|
|
Set the threshold below which log messages are printed even if the category itself is disabled.
|
|
||||||||||||||||
|
Split a long line into multiple lines, at most MaxLogLine characters long.
|
|
||||||||||||
|
Split a multi-line message into multiple lines, using L'
|
|
|
Return the threshold below which log messages are allowed unconditionally.
|
|
|
Unlock the log so that other threads can log messages. This should only be called if the current thread is the one who locked the log. |
|
|
Unregister the curent thread's indentation level placeholder. |
|
|
Turn off logging for categories matching a certain pattern.
|
|
||||||||||||||||
|
Log the content of a string stream.
|
|
|
Reference to the global data used for synchronization among threads. |
|
|
A hash table storing one integer pointer per thread. That integer pointer is provided by the logging thread and it is the address/location where the thread updates its current indentation level. The updating is done without locking because that address/location is assumed thread specific. |
|
|
The maximum length that a log line can have. Lines longer than this will be split. |
|
|
Mutex used to gain exclusive access to the output stream from within a thread. |
|
|
A vector of strings containing patterns. A log message's category must match at least one of these patterns in order to be logged. For now, matching means that the pattern must be the leading substring of the category. |
|
|
A bit mask containing flags to turn on/off certain parts of the preamble. See PreambleFlags for details. |
1.3.9.1