OpenWalnut  1.4.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes
WLogStream Class Reference

Class implementing a capsule for an output stream and the needed level and format information. More...

#include <WLogStream.h>

List of all members.

Public Types

typedef boost::shared_ptr
< WLogStream
SharedPtr
 shared pointer type
typedef WLogStreamPtr
 pointer type
typedef WLogStreamRef
 reference
typedef const WLogStreamConstRef
 const reference

Public Member Functions

 WLogStream (std::ostream &output, LogLevel logLevel=LL_DEBUG, std::string format="*%l [%s] %m \n", bool colored=true)
 Constructor.
void printEntry (const WLogEntry &entry)
 Prints the specified entry to the output stream in the right format if the log level matches.
void setLogLevel (LogLevel logLevel)
 Sets the new log level.
LogLevel getLogLevel () const
 Gets the currently set log level.
void setFormat (std::string format)
 Sets the format string.
std::string getFormat () const
 Returns the currently set format string.
void setColored (bool colors)
 Set whether to use colors or not.
bool isColored () const
 Getter determining whether to use colors or not.

Private Member Functions

 WLogStream (const WLogStream &rhs)
 Disallow copy.
WLogStreamoperator= (const WLogStream &rhs)
 Disallow assignment.

Private Attributes

std::ostream & m_output
 The output stream.
LogLevel m_logLevel
 The logging level.
std::string m_format
 The format of the message.
bool m_color
 True if colors should be used.

Detailed Description

Class implementing a capsule for an output stream and the needed level and format information.

Definition at line 37 of file WLogStream.h.


Member Typedef Documentation

const reference

Definition at line 43 of file WLogStream.h.

pointer type

Definition at line 41 of file WLogStream.h.

reference

Definition at line 42 of file WLogStream.h.

typedef boost::shared_ptr< WLogStream > WLogStream::SharedPtr

shared pointer type

Definition at line 40 of file WLogStream.h.


Constructor & Destructor Documentation

WLogStream::WLogStream ( std::ostream &  output,
LogLevel  logLevel = LL_DEBUG,
std::string  format = "*%l [%s] %m \n",
bool  colored = true 
)

Constructor.

Create a new stream instance. The output stream is a mandatory parameter. The others are predefined with some defaults.

Parameters:
outputthe stream where to print log messages to
logLevellogging level, i.e. verboseness
formatthe format used for output
coloredtrue if coloring should be used.

Definition at line 30 of file WLogStream.cpp.

WLogStream::WLogStream ( const WLogStream rhs) [private]

Disallow copy.

Parameters:
rhsthe stream to copy

Member Function Documentation

std::string WLogStream::getFormat ( ) const

Returns the currently set format string.

Returns:
format string.

Definition at line 66 of file WLogStream.cpp.

References m_format.

LogLevel WLogStream::getLogLevel ( ) const

Gets the currently set log level.

Returns:
the current log level

Definition at line 56 of file WLogStream.cpp.

References m_logLevel.

bool WLogStream::isColored ( ) const

Getter determining whether to use colors or not.

Returns:
true if colors should be used.

Definition at line 76 of file WLogStream.cpp.

References m_color.

WLogStream& WLogStream::operator= ( const WLogStream rhs) [private]

Disallow assignment.

Parameters:
rhsthe stream to assign to this
Returns:
this
void WLogStream::printEntry ( const WLogEntry entry)

Prints the specified entry to the output stream in the right format if the log level matches.

Parameters:
entrythe entry to print-

Definition at line 39 of file WLogStream.cpp.

References WLogEntry::getLogLevel(), WLogEntry::getLogString(), m_color, m_format, m_logLevel, and m_output.

void WLogStream::setColored ( bool  colors)

Set whether to use colors or not.

Note: this is only useful on Linux systems currently.

Parameters:
colorstrue if colors should be used.

Definition at line 71 of file WLogStream.cpp.

References m_color.

void WLogStream::setFormat ( std::string  format)

Sets the format string.

Parameters:
formatthe format string.

Definition at line 61 of file WLogStream.cpp.

References m_format.

void WLogStream::setLogLevel ( LogLevel  logLevel)

Sets the new log level.

All new incoming logs will be filtered according to this level.

Parameters:
logLevelthe level

Definition at line 51 of file WLogStream.cpp.

References m_logLevel.


Member Data Documentation

bool WLogStream::m_color [private]

True if colors should be used.

This requires a compatible terminal.

Definition at line 139 of file WLogStream.h.

Referenced by isColored(), printEntry(), and setColored().

std::string WLogStream::m_format [private]

The format of the message.

Definition at line 134 of file WLogStream.h.

Referenced by getFormat(), printEntry(), and setFormat().

LogLevel WLogStream::m_logLevel [private]

The logging level.

All messages below this level are discarded.

Definition at line 129 of file WLogStream.h.

Referenced by getLogLevel(), printEntry(), and setLogLevel().

std::ostream& WLogStream::m_output [private]

The output stream.

Definition at line 124 of file WLogStream.h.

Referenced by printEntry().


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