34 #include <boost/signals2/signal.hpp>
36 #include "WLogEntry.h"
37 #include "WLogStream.h"
38 #include "WSharedSequenceContainer.h"
39 #include "WStringUtils.h"
55 static void startup( std::ostream& output = std::cout, LogLevel level = LL_DEBUG );
111 void addLogMessage( std::string message, std::string source =
"", LogLevel level = LL_DEBUG );
147 WLogger( std::ostream& output, LogLevel level );
201 typedef std::basic_ostream< char, std::char_traits< char > > OutStreamType;
202 typedef OutStreamType& ( *StreamManipulatorFunctor )( OutStreamType& );
231 Buffer(
const std::string& source, LogLevel level );
255 : m_buffer( new
Buffer( source, level ) )
261 using string_utils::operator<<;
300 return _wlog( source, LL_ERROR );
311 return _wlog( source, LL_WARNING );
322 return _wlog( source, LL_INFO );
333 return _wlog( source, LL_DEBUG );
Represents a simple log message with some attributes.
std::shared_ptr< WLogStream > SharedPtr
shared pointer type
This class defines the interface for adding logs and managing several output streams for them.
boost::function< void(WLogEntry &) > LogEntryCallback
The type for all callbacks which get a log entry as parameter.
virtual ~WLogger()
Destructor.
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.
boost::signals2::signal< void(WLogEntry &) > m_addLogSignal
Signal called whenever a new log message arrives.
void addLogMessage(std::string message, std::string source="", LogLevel level=LL_DEBUG)
Appends a log message to the logging queue.
void removeStream(WLogStream::SharedPtr s)
Remove the given stream.
void setDefaultLogLevel(const LogLevel &level)
Set the default log-level used for log entries in default console-output.
WSharedSequenceContainer< std::vector< WLogStream::SharedPtr > > Outputs
The output stream list type.
static WLogger * getLogger()
Returns pointer to the currently running logger instance.
void setDefaultFormat(std::string format)
Set the default format used for log entries.
Outputs m_outputs
The list of outputs to print the messages to.
WLogger(const WLogger &)
We do not want a copy constructor, so we define it private.
LogEvent
Types of signals supported by the logger.
void addStream(WLogStream::SharedPtr s)
Adds a new stream to the logger.
std::string getDefaultFormat()
Gets the default format used for log entries.
WLogger(std::ostream &output, LogLevel level)
Constructor.
boost::signals2::connection subscribeSignal(LogEvent event, LogEntryCallback callback)
Subscribe to the specified signal.
This class provides a common interface for thread-safe access to sequence containers (list,...
Actually implementing the streaming functionality.
std::string m_source
The source of the logging message.
LogLevel m_level
Default logging level for this stream.
virtual ~Buffer()
Commits the logging expression to our WLogger.
Buffer(const std::string &source, LogLevel level)
Constructs a new stream for logging.
std::ostringstream m_logString
queuing up parts of the log message
Resource class for streamed logging.
WStreamedLogger(const std::string &source, LogLevel level)
Creates new streamed logger instance.
WStreamedLogger operator<<(const T &loggable)
Appends something loggable (to std::string castable) to the log.
std::shared_ptr< Buffer > m_buffer
Collects the message parts.
WStreamedLogger & operator=(const WStreamedLogger &rhs)=delete
Forbid assignment.
This namespace collects several convenient access points such as wlog::err for logging with streams t...
WStreamedLogger debug(const std::string &source)
Logging a debug 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 warn(const std::string &source)
Logging a warning message.
WStreamedLogger info(const std::string &source)
Logging an information message.
WStreamedLogger error(const std::string &source)
Logging an error message.