![]() |
OpenWalnut
1.5.0dev
|
Class implementing a capsule for an output stream and the needed level and format information. More...
#include <WLogStream.h>
Collaboration diagram for WLogStream:Public Types | |
| typedef std::shared_ptr< WLogStream > | SharedPtr |
| shared pointer type More... | |
| typedef WLogStream * | Ptr |
| pointer type More... | |
| typedef WLogStream & | Ref |
| reference More... | |
| typedef const WLogStream & | ConstRef |
| const reference More... | |
Public Member Functions | |
| WLogStream (std::ostream &output, LogLevel logLevel=LL_DEBUG, std::string format="*%l [%s] %m \n", bool colored=true) | |
| Constructor. More... | |
| void | printEntry (const WLogEntry &entry) |
| Prints the specified entry to the output stream in the right format if the log level matches. More... | |
| void | setLogLevel (LogLevel logLevel) |
| Sets the new log level. More... | |
| LogLevel | getLogLevel () const |
| Gets the currently set log level. More... | |
| void | setFormat (std::string format) |
| Sets the format string. More... | |
| std::string | getFormat () const |
| Returns the currently set format string. More... | |
| void | setColored (bool colors) |
| Set whether to use colors or not. More... | |
| bool | isColored () const |
| Getter determining whether to use colors or not. More... | |
Private Member Functions | |
| WLogStream (const WLogStream &rhs) | |
| Disallow copy. More... | |
| WLogStream & | operator= (const WLogStream &rhs) |
| Disallow assignment. More... | |
Private Attributes | |
| std::ostream & | m_output |
| The output stream. More... | |
| LogLevel | m_logLevel |
| The logging level. More... | |
| std::string | m_format |
| The format of the message. More... | |
| bool | m_color |
| True if colors should be used. More... | |
Class implementing a capsule for an output stream and the needed level and format information.
Definition at line 38 of file WLogStream.h.
| typedef const WLogStream& WLogStream::ConstRef |
const reference
Definition at line 44 of file WLogStream.h.
| typedef WLogStream* WLogStream::Ptr |
pointer type
Definition at line 42 of file WLogStream.h.
| typedef WLogStream& WLogStream::Ref |
reference
Definition at line 43 of file WLogStream.h.
| typedef std::shared_ptr< WLogStream > WLogStream::SharedPtr |
shared pointer type
Definition at line 41 of file WLogStream.h.
| WLogStream::WLogStream | ( | std::ostream & | output, |
| LogLevel | logLevel = LL_DEBUG, |
||
| std::string | format = "*%l [%s] %m \n", |
||
| bool | colored = true |
||
| ) |
Constructor.
Create a new stream instance. The output stream is a mandatory parameter. The others are predefined with some defaults.
| output | the stream where to print log messages to |
| logLevel | logging level, i.e. verboseness |
| format | the format used for output |
| colored | true if coloring should be used. |
Definition at line 30 of file WLogStream.cpp.
|
private |
Disallow copy.
| rhs | the stream to copy |
| std::string WLogStream::getFormat | ( | ) | const |
Returns the currently set format string.
Definition at line 66 of file WLogStream.cpp.
References m_format.
| LogLevel WLogStream::getLogLevel | ( | ) | const |
Gets the currently set log level.
Definition at line 56 of file WLogStream.cpp.
References m_logLevel.
| bool WLogStream::isColored | ( | ) | const |
Getter determining whether to use colors or not.
Definition at line 76 of file WLogStream.cpp.
References m_color.
|
private |
Disallow assignment.
| rhs | the stream to assign to this |
| void WLogStream::printEntry | ( | const WLogEntry & | entry | ) |
Prints the specified entry to the output stream in the right format if the log level matches.
| entry | the entry to print- |
Definition at line 39 of file WLogStream.cpp.
References WLogEntry::getLogLevel(), WLogEntry::getLogString(), m_color, m_format, m_logLevel, and m_output.
Here is the call graph for this function:| void WLogStream::setColored | ( | bool | colors | ) |
Set whether to use colors or not.
Note: this is only useful on Linux systems currently.
| colors | true if colors should be used. |
Definition at line 71 of file WLogStream.cpp.
References m_color.
| void WLogStream::setFormat | ( | std::string | format | ) |
Sets the format string.
| format | the format string. |
Definition at line 61 of file WLogStream.cpp.
References m_format.
| void WLogStream::setLogLevel | ( | LogLevel | logLevel | ) |
Sets the new log level.
All new incoming logs will be filtered according to this level.
| logLevel | the level |
Definition at line 51 of file WLogStream.cpp.
References m_logLevel.
|
private |
True if colors should be used.
This requires a compatible terminal.
Definition at line 140 of file WLogStream.h.
Referenced by isColored(), printEntry(), and setColored().
|
private |
The format of the message.
Definition at line 135 of file WLogStream.h.
Referenced by getFormat(), printEntry(), and setFormat().
|
private |
The logging level.
All messages below this level are discarded.
Definition at line 130 of file WLogStream.h.
Referenced by getLogLevel(), printEntry(), and setLogLevel().
|
private |