28 #include <boost/date_time/posix_time/posix_time.hpp>
29 #include <boost/filesystem/fstream.hpp>
31 #include "exceptions/WSignalSubscriptionInvalid.h"
32 #include "exceptions/WPreconditionNotMet.h"
45 logger =
new WLogger( output, level );
55 addLogMessage(
"===============================================================================",
"Logger", LL_INFO );
56 addLogMessage(
"= Starting Log Session =",
"Logger", LL_INFO );
57 addLogMessage(
"===============================================================================",
"Logger", LL_INFO );
80 throw new WSignalSubscriptionInvalid( std::string(
"Signal could not be subscribed. The event is not compatible with the callback." ) );
86 boost::posix_time::ptime t( boost::posix_time::second_clock::local_time() );
87 std::string timeString( to_simple_string( t ) );
88 WLogEntry entry( timeString, message, level, source );
97 ( *i )->printEntry( entry );
Represents a simple log message with some attributes.
Class implementing a capsule for an output stream and the needed level and format information.
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.
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.
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.
An exception that gets thrown when preconditions of a function are not met.
std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
ReadTicket getReadTicket() const
Returns a ticket to get read access to the contained data.
void remove(const typename S::value_type &element)
Searches and removes the specified element.
void push_back(const typename S::value_type &x)
Adds a new element at the end of the container.
S::const_iterator ConstIterator
A typedef for the correct const iterator useful to traverse this sequence container.
Indicates invalid use of subscribeSignal methods.
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.
std::ostringstream m_logString
queuing up parts of the log message