|
CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
|
A class implementing a logging system. More...
#include <logger.hpp>
Public Types | |
| typedef log_stream | stream_type |
| typedef std::list< stream_type * > | stream_list_type |
Public Member Functions | |
| CLAW_LOGGER_EXPORT | log_system () |
| Default constructor. | |
| CLAW_LOGGER_EXPORT | ~log_system () |
| Destructor. | |
| CLAW_LOGGER_EXPORT void | clear () |
| Delete the streams. | |
| CLAW_LOGGER_EXPORT void | merge (stream_type *s) |
| Add an other output stream. | |
| CLAW_LOGGER_EXPORT void | remove (const stream_type *s) |
| Remove a stream. | |
| CLAW_LOGGER_EXPORT void | set (stream_type *s) |
| Set the output stream. | |
| CLAW_LOGGER_EXPORT void | set_level (int lvl) |
| Change the level of log. | |
| CLAW_LOGGER_EXPORT void | set_level (const log_level &lvl) |
| Change the level of log. | |
| CLAW_LOGGER_EXPORT void | flush () |
| Flush all log streams. | |
| template<typename T > | |
| log_system & | operator<< (const T &that) |
| Log something. | |
| CLAW_LOGGER_EXPORT log_system & | operator<< (const log_level &that) |
| Change the level of the next mesasges. | |
| CLAW_LOGGER_EXPORT log_system & | operator<< (log_system &(*pf)(log_system &)) |
| Apply a stream modifier function to the log_system. | |
Private Attributes | |
| int | m_log_level |
| The level of log. Messages are ignored if their level is greater than this level. | |
| int | m_message_level |
| The current message level, for operator <<. | |
| stream_list_type | m_stream |
| The streams in which we write de log informations. | |
A class implementing a logging system.
Messages are sent to the log system. If the importance (level) of a message is lower or equal to a given threshold, the message is printed. Otherwise, it is ignored.
Message printing is managed by log_stream classes. The logger_system can contain several log_stream. None checking is done when adding a log_stream to see if it is already in the system.
Definition at line 71 of file logger.hpp.
| typedef std::list<stream_type*> claw::log_system::stream_list_type |
Definition at line 75 of file logger.hpp.
Definition at line 74 of file logger.hpp.
| claw::log_system::log_system | ( | ) |
Default constructor.
The logger is initialized with a console logger.
Definition at line 45 of file logger.cpp.
: m_log_level(-1), m_message_level(0) { } // log_system::~log_system()
| claw::log_system::~log_system | ( | ) |
| void claw::log_system::clear | ( | ) |
Delete the streams.
Definition at line 64 of file logger.cpp.
Referenced by claw::application::~application().
| void claw::log_system::flush | ( | ) |
Flush all log streams.
Definition at line 134 of file logger.cpp.
{
if (m_message_level <= m_log_level)
{
stream_list_type::iterator it;
for ( it=m_stream.begin(); it!=m_stream.end(); ++it )
(*it)->flush();
}
} // log_system::flush()
| void claw::log_system::merge | ( | stream_type * | s | ) |
Add an other output stream.
| s | Dynamicaly allocated logger_stream. |
Definition at line 79 of file logger.cpp.
{
m_stream.push_front(s);
} // log_system::merge()
| claw::log_system & claw::log_system::operator<< | ( | const log_level & | that | ) |
Change the level of the next mesasges.
| that | The new level. |
Definition at line 150 of file logger.cpp.
References claw::log_level::get(), and claw::log_level::get_string().
{
m_message_level = that.get();
if (m_message_level <= m_log_level)
*this << that.get_string();
return *this;
} // log_system::operator<<() [log_level]
| claw::log_system & claw::log_system::operator<< | ( | const T & | t | ) |
Log something.
| t | The thing to log... |
Definition at line 39 of file logger.tpp.
References m_log_level, m_message_level, and m_stream.
{
if (m_message_level <= m_log_level)
{
std::ostringstream oss;
oss << t;
typename stream_list_type::iterator it;
for (it = m_stream.begin(); it!=m_stream.end(); ++it)
(*it)->write(oss.str());
}
return *this;
} // log_system::operator<<()
| claw::log_system & claw::log_system::operator<< | ( | log_system &(*)(log_system &) | pf | ) |
Apply a stream modifier function to the log_system.
| pf | The function to apply. |
Definition at line 166 of file logger.cpp.
{
return pf(*this);
} // log_system::operator<<() [log_system& (*pf)(log_system&)]
| void claw::log_system::remove | ( | const stream_type * | s | ) |
Remove a stream.
| s | The stream to remove. |
Definition at line 90 of file logger.cpp.
| void claw::log_system::set | ( | stream_type * | s | ) |
Set the output stream.
| s | Dynamicaly allocated logger_stream. |
Definition at line 104 of file logger.cpp.
Referenced by claw::application::application().
| void claw::log_system::set_level | ( | int | lvl | ) |
Change the level of log.
| lvl | New level. |
Definition at line 115 of file logger.cpp.
Referenced by claw::application::application().
{
m_log_level = lvl;
} // log_system::set_level()
| void claw::log_system::set_level | ( | const log_level & | lvl | ) |
Change the level of log.
| lvl | New level. |
Definition at line 125 of file logger.cpp.
References claw::log_level::get().
{
m_log_level = lvl.get();
} // log_system::set_level()
int claw::log_system::m_log_level [private] |
The level of log. Messages are ignored if their level is greater than this level.
Definition at line 99 of file logger.hpp.
Referenced by operator<<().
int claw::log_system::m_message_level [private] |
The current message level, for operator <<.
Definition at line 102 of file logger.hpp.
Referenced by operator<<().
stream_list_type claw::log_system::m_stream [private] |
The streams in which we write de log informations.
Definition at line 105 of file logger.hpp.
Referenced by operator<<().
1.7.3