34 #include <boost/shared_ptr.hpp>
37 #include <boost/signals2/signal.hpp>
40 #include "WLogEntry.h"
41 #include "WLogStream.h"
42 #include "WStringUtils.h"
43 #include "WSharedSequenceContainer.h"
59 static void startup( std::ostream& output = std::cout, LogLevel level = LL_DEBUG );
115 void addLogMessage( std::string message, std::string source =
"", LogLevel level = LL_DEBUG );
151 WLogger( std::ostream& output, LogLevel level );
205 typedef std::basic_ostream< char, std::char_traits< char > > OutStreamType;
206 typedef OutStreamType& ( *StreamManipulatorFunctor )( OutStreamType& );
235 Buffer(
const std::string& source, LogLevel level );
259 : m_buffer( new
Buffer( source, level ) )
265 using string_utils::operator<<;
304 return _wlog( source, LL_ERROR );
315 return _wlog( source, LL_WARNING );
326 return _wlog( source, LL_INFO );
337 return _wlog( source, LL_DEBUG );
WStreamedLogger error(const std::string &source)
Logging an error message.
WStreamedLogger _wlog(const std::string &source, LogLevel level)
Convenient function for logging messages to our WLogger but not for public use outside of this module...
WStreamedLogger operator<<(const T &loggable)
Appends something loggable (to std::string castable) to the log.
WStreamedLogger(const std::string &source, LogLevel level)
Creates new streamed logger instance.
boost::function< void(WLogEntry &) > LogEntryCallback
The type for all callbacks which get a log entry as parameter.
WSharedSequenceContainer< std::vector< WLogStream::SharedPtr > > Outputs
The output stream list type.
std::string m_source
The source of the logging message.
WStreamedLogger info(const std::string &source)
Logging an information message.
void setDefaultLogLevel(const LogLevel &level)
Set the default log-level used for log entries in default console-output.
WStreamedLogger & operator=(const WStreamedLogger &rhs)
Forbid assignment.
This namespace collects several convenient access points such as wlog::err for logging with streams t...
static WLogger * getLogger()
Returns pointer to the currently running logger instance.
This class provides a common interface for thread-safe access to sequence containers (list...
void addLogMessage(std::string message, std::string source="", LogLevel level=LL_DEBUG)
Appends a log message to the logging queue.
Buffer(const std::string &source, LogLevel level)
Constructs a new stream for logging.
This class defines the interface for adding logs and managing several output streams for them...
boost::shared_ptr< Buffer > m_buffer
Collects the message parts.
Outputs m_outputs
The list of outputs to print the messages to.
boost::signals2::signal< void(WLogEntry &) > m_addLogSignal
Signal called whenever a new log message arrives.
static void startup(std::ostream &output=std::cout, LogLevel level=LL_DEBUG)
Create the first and only instance of the logger as it is a singleton.
Resource class for streamed logging.
boost::signals2::connection subscribeSignal(LogEvent event, LogEntryCallback callback)
Subscribe to the specified signal.
boost::shared_ptr< WLogStream > SharedPtr
shared pointer type
Actually implementing the streaming functionality.
std::string getDefaultFormat()
Gets the default format used for log entries.
LogLevel m_level
Default logging level for this stream.
void removeStream(WLogStream::SharedPtr s)
Remove the given stream.
std::ostringstream m_logString
queuing up parts of the log message
virtual ~WLogger()
Destructor.
void setDefaultFormat(std::string format)
Set the default format used for log entries.
WLogger(std::ostream &output, LogLevel level)
Constructor.
virtual ~Buffer()
Commits the logging expression to our WLogger.
WStreamedLogger debug(const std::string &source)
Logging a debug message.
void addStream(WLogStream::SharedPtr s)
Adds a new stream to the logger.
WStreamedLogger warn(const std::string &source)
Logging a warning message.
LogEvent
Types of signals supported by the logger.