log_stream template class More...
#include <Logger.h>
Public Types | |
typedef _CharT | char_type |
typedef _Traits | traits_type |
typedef std::basic_ostream < char_type, traits_type > | ostream_type |
typedef std::basic_streambuf < char_type, traits_type > | streambuf_type |
typedef coil::Mutex | Mutex |
typedef coil::Guard< Mutex > | Guard |
Public Member Functions | |
log_stream (streambuf_type *sb, int levelmin, int levelmax, int level) | |
Constructor. | |
virtual void | header (int level) |
Message header appender function. | |
bool | setLevel (int level) |
Set the log level. | |
int | getLevel () const |
Get the log level. | |
void | enableLock () |
void | disableLock () |
ostream_type & | level (int level) |
Acquire log stream. | |
bool | isValid (int level) const |
Log level effective check. | |
void | lock () |
Acquire log lock Acquire log lock when the lock mode is set. | |
void | unlock () |
Release the log lock Release the log lock when the lock mode is set. | |
Static Public Attributes | |
static bool | m_lockEnable = true |
Lock enable mode. | |
static Mutex | m_mutex |
Mutual exclusion object. | |
Protected Member Functions | |
~log_stream () | |
Destructor. | |
log_stream () | |
Default constructor. | |
log_stream (const log_stream &x) | |
Copy Constructor. | |
log_stream & | operator= (const log_stream &x) |
Assignment operator. |
log_stream template class
typedef _CharT coil::log_stream< _CharT, _Traits >::char_type |
typedef coil::Guard<Mutex> coil::log_stream< _CharT, _Traits >::Guard |
typedef coil::Mutex coil::log_stream< _CharT, _Traits >::Mutex |
typedef std::basic_ostream<char_type, traits_type> coil::log_stream< _CharT, _Traits >::ostream_type |
typedef std::basic_streambuf<char_type, traits_type> coil::log_stream< _CharT, _Traits >::streambuf_type |
typedef _Traits coil::log_stream< _CharT, _Traits >::traits_type |
coil::log_stream< _CharT, _Traits >::log_stream | ( | streambuf_type * | sb, | |
int | levelmin, | |||
int | levelmax, | |||
int | level | |||
) | [inline] |
Constructor.
Constructor
streambuf | basic_streambuf type object | |
levelmin | minimum value for log level | |
levelmax | maximum value for log level | |
level | default log level |
coil::log_stream< _CharT, _Traits >::~log_stream | ( | ) | [inline, protected] |
Destructor.
Destructor
coil::log_stream< _CharT, _Traits >::log_stream | ( | ) | [protected] |
Default constructor.
Default constructor
coil::log_stream< _CharT, _Traits >::log_stream | ( | const log_stream< _CharT, _Traits > & | x | ) | [protected] |
void coil::log_stream< _CharT, _Traits >::disableLock | ( | ) | [inline] |
Disable the lock mode.
References coil::log_stream< _CharT, _Traits >::m_lockEnable.
void coil::log_stream< _CharT, _Traits >::enableLock | ( | ) | [inline] |
Enable the lock mode.
References coil::log_stream< _CharT, _Traits >::m_lockEnable.
int coil::log_stream< _CharT, _Traits >::getLevel | ( | ) | const [inline] |
Get the log level.
Get the log level.
virtual void coil::log_stream< _CharT, _Traits >::header | ( | int | level | ) | [inline, virtual] |
Message header appender function.
Subclasses of this class should override this operation, and this function should be defined to append some header to the log messages.
Reimplemented in RTC::Logger.
Referenced by coil::log_stream< _CharT, _Traits >::level().
bool coil::log_stream< _CharT, _Traits >::isValid | ( | int | level | ) | const [inline] |
Log level effective check.
Check it whether an appointed log level is an effective range and return effective or invalidity.
level | Log level |
ostream_type& coil::log_stream< _CharT, _Traits >::level | ( | int | level | ) | [inline] |
Acquire log stream.
Investigate the specified log level and get its log stream. If the specified log level is under the set log level, this class will be returned. If the specified log level exceeds the set log level, a dummy log class will be returned.
level | The specified log level |
References coil::log_stream< _CharT, _Traits >::header().
void coil::log_stream< _CharT, _Traits >::lock | ( | ) | [inline] |
Acquire log lock Acquire log lock when the lock mode is set.
References coil::Mutex::lock(), coil::log_stream< _CharT, _Traits >::m_lockEnable, and coil::log_stream< _CharT, _Traits >::m_mutex.
log_stream& coil::log_stream< _CharT, _Traits >::operator= | ( | const log_stream< _CharT, _Traits > & | x | ) | [protected] |
Assignment operator.
Copy a log_stream object.
x | log_stream object. |
bool coil::log_stream< _CharT, _Traits >::setLevel | ( | int | level | ) | [inline] |
Set the log level.
Set the log level.
level | Log level |
void coil::log_stream< _CharT, _Traits >::unlock | ( | ) | [inline] |
Release the log lock Release the log lock when the lock mode is set.
References coil::log_stream< _CharT, _Traits >::m_lockEnable, coil::log_stream< _CharT, _Traits >::m_mutex, and coil::Mutex::unlock().
bool coil::log_stream< _CharT, _Traits >::m_lockEnable = true [inline, static] |
coil::Mutex coil::log_stream< _CharT, _Traits >::m_mutex [inline, static] |
Mutual exclusion object.
Referenced by coil::log_stream< _CharT, _Traits >::lock(), and coil::log_stream< _CharT, _Traits >::unlock().