IBR-DTNSuite  0.12
ibrcommon::LogWriter Class Reference

#include <Logger.h>

Inheritance diagram for ibrcommon::LogWriter:
Inheritance graph
Collaboration diagram for ibrcommon::LogWriter:
Collaboration graph

Public Member Functions

virtual ~LogWriter ()
 
void log (Logger &logger)
 
void setVerbosity (const int verbosity)
 
int getVerbosity () const
 
unsigned char getLogMask () const
 
void addStream (std::ostream &stream, const unsigned char logmask=Logger::LOGGER_INFO, const unsigned char options=Logger::LOG_NONE)
 
void setLogfile (const ibrcommon::File &logfile, const unsigned char logmask=Logger::LOGGER_INFO, const unsigned char options=Logger::LOG_NONE)
 
void enableSyslog (const char *name, int option, int facility, const unsigned char logmask=Logger::LOGGER_INFO)
 
void enableAsync ()
 
void enableBuffer (size_t size)
 
void reload ()
 
void writeBuffer (std::ostream &, const unsigned char logmask, const unsigned char options)
 
const std::string & getDefaultTag () const
 
void setDefaultTag (const std::string &value)
 
- Public Member Functions inherited from ibrcommon::JoinableThread
virtual ~JoinableThread ()=0
 
void join (void) throw (ThreadException)
 
bool isRunning (void)
 
void start (int priority=0) throw (ThreadException)
 
void stop () throw ()
 

Static Public Member Functions

static LogWritergetInstance ()
 

Protected Member Functions

void flush ()
 
void run () throw ()
 
void __cancellation () throw ()
 
- Protected Member Functions inherited from ibrcommon::JoinableThread
 JoinableThread (size_t size=DEFAULT_STACKSIZE)
 
- Protected Member Functions inherited from ibrcommon::Thread
virtual ~Thread ()=0
 
void reset () throw (ThreadException)
 
virtual void setup (void) throw ()
 
virtual void finally (void) throw ()
 
bool isFinalized () throw ()
 
bool operator== (const ibrcommon::Thread &other)
 
 Thread (size_t stack=DEFAULT_STACKSIZE)
 
int kill (int sig)
 
void cancel () throw ()
 

Additional Inherited Members

- Static Protected Member Functions inherited from ibrcommon::Thread
static size_t getNumberOfProcessors ()
 
static void yield (void)
 
static void sleep (time_t timeout)
 
static void concurrency (int level)
 
static bool equal (pthread_t thread1, pthread_t thread2)
 
static void * __execute__ (void *obj) throw ()
 

Detailed Description

Definition at line 286 of file Logger.h.

Constructor & Destructor Documentation

ibrcommon::LogWriter::~LogWriter ( )
virtual

Definition at line 498 of file Logger.cpp.

References ibrcommon::JoinableThread::join(), and ibrcommon::JoinableThread::stop().

Here is the call graph for this function:

Member Function Documentation

void ibrcommon::LogWriter::__cancellation ( )
throw (
)
protectedvirtual

Implements ibrcommon::Thread.

Definition at line 656 of file Logger.cpp.

void ibrcommon::LogWriter::addStream ( std::ostream &  stream,
const unsigned char  logmask = Logger::LOGGER_INFO,
const unsigned char  options = Logger::LOG_NONE 
)

Add a standard output stream to the logging framework.

Parameters
streamStandard output stream
logmaskThis mask specify what will be written to this stream. You can combine options with the or function.
optionsThis mask specify what will be added to each log message. You can combine options with the or function.

Definition at line 152 of file Logger.cpp.

Referenced by ibrcommon::Logger::addStream().

void ibrcommon::LogWriter::enableAsync ( )

enable the asynchronous logging This starts a seperate thread and a thread-safe queue to queue all logging messages first and call the log routine by the thread. This option is nessacary, if the stream to log into are not thread-safe by itself.

Definition at line 438 of file Logger.cpp.

References ibrcommon::LogLevel::error, IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, ibrcommon::JoinableThread::start(), and ibrcommon::Exception::what().

Referenced by ibrcommon::Logger::enableAsync().

Here is the call graph for this function:

void ibrcommon::LogWriter::enableBuffer ( size_t  size)

Enables the internal ring-buffer.

Parameters
sizeThe size of the buffer.

Definition at line 511 of file Logger.cpp.

Referenced by ibrcommon::Logger::enableBuffer().

void ibrcommon::LogWriter::enableSyslog ( const char *  name,
int  option,
int  facility,
const unsigned char  logmask = Logger::LOGGER_INFO 
)

Enable logging message to the system syslog.

Parameters
nameThe naming prefix for all log messages.
optionSyslog specific options.
See Also
syslog.h
Parameters
facilitySyslog facility.
See Also
syslog.h
Parameters
logmaskThis mask specify what will be written to the syslog. You can combine options with the or function.

Definition at line 168 of file Logger.cpp.

Referenced by ibrcommon::Logger::enableSyslog().

void ibrcommon::LogWriter::flush ( )
protected

Referenced by log(), and run().

const std::string & ibrcommon::LogWriter::getDefaultTag ( ) const

Return the default tag

Definition at line 595 of file Logger.cpp.

unsigned char ibrcommon::LogWriter::getLogMask ( ) const

Definition at line 132 of file Logger.cpp.

Referenced by ibrcommon::Logger::getLogMask().

int ibrcommon::LogWriter::getVerbosity ( ) const

Get the global verbosity of the logger.

Returns
The verbosity level as number. Higher value leads to more output.

Definition at line 137 of file Logger.cpp.

Referenced by ibrcommon::Logger::getVerbosity().

void ibrcommon::LogWriter::log ( Logger logger)

Definition at line 605 of file Logger.cpp.

References flush().

Referenced by ibrcommon::Logger::print().

Here is the call graph for this function:

void ibrcommon::LogWriter::reload ( )

Reload the logger. This re-opens the logfile for output.

Definition at line 554 of file Logger.cpp.

References ibrcommon::File::getPath().

Referenced by ibrcommon::Logger::reload().

Here is the call graph for this function:

void ibrcommon::LogWriter::run ( )
throw (
)
protectedvirtual

Abstract interface for thread context run method.

Implements ibrcommon::Thread.

Definition at line 617 of file Logger.cpp.

References ibrcommon::Queue< T >::Locked::empty(), flush(), ibrcommon::Queue< T >::Locked::front(), and ibrcommon::Queue< T >::Locked::pop().

Here is the call graph for this function:

void ibrcommon::LogWriter::setDefaultTag ( const std::string &  value)

set the default tag to log

Definition at line 600 of file Logger.cpp.

Referenced by ibrcommon::Logger::setDefaultTag().

void ibrcommon::LogWriter::setLogfile ( const ibrcommon::File logfile,
const unsigned char  logmask = Logger::LOGGER_INFO,
const unsigned char  options = Logger::LOG_NONE 
)

Set the logfile for the logging framework.

Parameters
logfileThe file to log into.
logmaskThis mask specify what will be written to this stream. You can combine options with the or function.
optionsThis mask specify what will be added to each log message. You can combine options with the or function.

Definition at line 518 of file Logger.cpp.

References ibrcommon::File::getPath().

Referenced by ibrcommon::Logger::setLogfile().

Here is the call graph for this function:

void ibrcommon::LogWriter::setVerbosity ( const int  verbosity)

Set the global verbosity of the logger.

Parameters
verbosityA verbosity level as number. Higher value leads to more output.

Definition at line 117 of file Logger.cpp.

Referenced by ibrcommon::Logger::setVerbosity().

void ibrcommon::LogWriter::writeBuffer ( std::ostream &  stream,
const unsigned char  logmask,
const unsigned char  options 
)

Write the buffer to a stream

Parameters

Definition at line 581 of file Logger.cpp.

Referenced by ibrcommon::Logger::writeBuffer().


The documentation for this class was generated from the following files: