RTT::Logger Class Reference

#include <Logger.hpp>

List of all members.

Classes

struct  D
struct  In

Public Types

typedef std::ostream &(* LogFunction )(std::ostream &)
typedef std::ostream &(* LogFunction )(std::ostream &)
enum  LogLevel {
  Never = 0, Fatal, Critical, Error,
  Warning, Info, Debug, RealTime,
  Never = 0, Fatal, Critical, Error,
  Warning, Info, Debug, RealTime
}
enum  LogLevel {
  Never = 0, Fatal, Critical, Error,
  Warning, Info, Debug, RealTime,
  Never = 0, Fatal, Critical, Error,
  Warning, Info, Debug, RealTime
}

Public Member Functions

void allowRealTime ()
void allowRealTime ()
void disallowRealTime ()
void disallowRealTime ()
LogLevel getLogLevel () const
LogLevel getLogLevel () const
std::string getLogLine ()
std::string getLogLine ()
std::string getLogModule () const
std::string getLogModule () const
os::TimeService::ticks getReferenceTime () const
os::TimeService::ticks getReferenceTime () const
Loggerin (const std::string &modname)
Loggerin (const std::string &modname)
void logendl ()
void logendl ()
void logflush ()
void logflush ()
void lognl ()
void lognl ()
void mayLogFile (bool tf)
void mayLogFile (bool tf)
void mayLogStdOut (bool tf)
void mayLogStdOut (bool tf)
Loggeroperator<< (std::ostream &(*pf)(std::ostream &))
Loggeroperator<< (const char *)
Loggeroperator<< (const std::string &)
Loggeroperator<< (LogLevel ll)
template<class T >
Loggeroperator<< (T t)
Loggeroperator<< (std::ostream &(*pf)(std::ostream &))
Loggeroperator<< (const char *)
Loggeroperator<< (const std::string &)
Loggeroperator<< (LogLevel ll)
template<class T >
Loggeroperator<< (T t)
Loggerout (const std::string &modname)
Loggerout (const std::string &modname)
void setLogLevel (LogLevel ll)
void setLogLevel (LogLevel ll)
void setStdStream (std::ostream &stdos)
void setStdStream (std::ostream &stdos)
void shutdown ()
void shutdown ()
void startup ()
void startup ()

Static Public Member Functions

static std::ostream & endl (std::ostream &__os)
static std::ostream & endl (std::ostream &__os)
static std::ostream & flush (std::ostream &__os)
static std::ostream & flush (std::ostream &__os)
static LoggerInstance (std::ostream &str=std::cerr)
static LoggerInstance (std::ostream &str=std::cerr)
static Loggerlog (LogLevel ll)
static Loggerlog ()
static Loggerlog (LogLevel ll)
static Loggerlog ()
static std::ostream & nl (std::ostream &__os)
static std::ostream & nl (std::ostream &__os)
static void Release ()
static void Release ()

Private Member Functions

 Logger (std::ostream &str=std::cerr)
 Logger (std::ostream &str=std::cerr)
bool mayLog () const
bool mayLog () const
bool mayLogFile () const
bool mayLogFile () const
bool mayLogStdOut () const
bool mayLogStdOut () const
 ~Logger ()
 ~Logger ()

Private Attributes

Dd
std::ostream & fileline
os::Mutexinpguard
std::ostream & logline

Static Private Attributes

static Logger_instance = 0

Detailed Description

A simple logging class to debug/ analyse what is going on in the Orocos system. You MUST NOT use this logger in a HARD realtime task or thread.

You can disable all logging at compile time by defining OROBLD_DISABLE_LOGGING (not advised for normal usage). This class can log to a console, and/or to a file and/or to an internal buffer which may be emptied by another class. This is decided upon compile time and can not be changed during runtime. Both printf/iostream are supported.

Example Usage :

     Logger::log() << Logger::Error << "An error Occured !" << Logger::endl;
     Logger::log() << Logger::Debug << "All debug info ..." << Logger::endl;
     * 

When the application is started, set the displayed loglevel with setLogLevel() with a LogLevel parameter. The default is Warning. Set the desired log streams ( a file or std output ) with logToStream() and setStdStream(). Additionally, an orocos.log which is always logs at log level 'Info'.

If you set an environment variable ORO_LOGLEVEL=0..6, this value will be used to determine the output level until overriden by the application (if so). The ORO_LOGLEVEL has the same effect on the 'orocos.log' file, but can not lower it below "Info".

Warning:
Use Logger::RealTime to log from real-time threads. As long as the output LogLevel is 6 or lower, these messages will not appear and do no harm to real-time performance. You need to call
Logger::log().allowRealTime(); 
once in your program to confirm this choice. AGAIN: THIS WILL BREAK REAL-TIME PERFORMANCE.

Definition at line 91 of file install/include/rtt/Logger.hpp.


Member Typedef Documentation

typedef std::ostream&(* RTT::Logger::LogFunction)(std::ostream &)

Function signature of the functions that influence the log stream.

Definition at line 186 of file rtt/Logger.hpp.

typedef std::ostream&(* RTT::Logger::LogFunction)(std::ostream &)

Function signature of the functions that influence the log stream.

Definition at line 145 of file install/include/rtt/Logger.hpp.


Member Enumeration Documentation

Enumerate all log-levels from absolute silence to everything.

Warning:
If you enable 'RealTime' logging, this may break realtime performance. Use With Care and NOT on production systems.
See also:
allowRealTime()
Enumerator:
Never 
Fatal 
Critical 
Error 
Warning 
Info 
Debug 
RealTime 
Never 
Fatal 
Critical 
Error 
Warning 
Info 
Debug 
RealTime 

Definition at line 121 of file rtt/Logger.hpp.

Enumerate all log-levels from absolute silence to everything.

Warning:
If you enable 'RealTime' logging, this may break realtime performance. Use With Care and NOT on production systems.
See also:
allowRealTime()
Enumerator:
Never 
Fatal 
Critical 
Error 
Warning 
Info 
Debug 
RealTime 
Never 
Fatal 
Critical 
Error 
Warning 
Info 
Debug 
RealTime 

Definition at line 80 of file install/include/rtt/Logger.hpp.


Constructor & Destructor Documentation

RTT::Logger::Logger ( std::ostream &  str = std::cerr  )  [private]

Definition at line 296 of file Logger.cpp.

RTT::Logger::~Logger (  )  [private]

Definition at line 303 of file Logger.cpp.

RTT::Logger::Logger ( std::ostream &  str = std::cerr  )  [private]
RTT::Logger::~Logger (  )  [private]

Member Function Documentation

void RTT::Logger::allowRealTime (  ) 

Allow messages of the LogLevel 'RealTime' to appear on the console.

void RTT::Logger::allowRealTime (  ) 

Allow messages of the LogLevel 'RealTime' to appear on the console.

Definition at line 328 of file Logger.cpp.

void RTT::Logger::disallowRealTime (  ) 

Disallow messages of the LogLevel 'RealTime' to appear on the console.

void RTT::Logger::disallowRealTime (  ) 

Disallow messages of the LogLevel 'RealTime' to appear on the console.

Definition at line 332 of file Logger.cpp.

static std::ostream& RTT::Logger::endl ( std::ostream &  __os  )  [static]
std::ostream & RTT::Logger::endl ( std::ostream &  __os  )  [static]

Definition at line 353 of file Logger.cpp.

static std::ostream& RTT::Logger::flush ( std::ostream &  __os  )  [static]

Flush the output stream.

std::ostream & RTT::Logger::flush ( std::ostream &  __os  )  [static]

Flush the output stream.

Definition at line 363 of file Logger.cpp.

LogLevel RTT::Logger::getLogLevel (  )  const

Return the current output loglevel.

Logger::LogLevel RTT::Logger::getLogLevel (  )  const

Return the current output loglevel.

Definition at line 580 of file Logger.cpp.

std::string RTT::Logger::getLogLine (  ) 

This method gets all messages upto level Info and can be freely read by the user, removing the line from an internal buffer of Logger.

std::string RTT::Logger::getLogLine (  ) 

This method gets all messages upto level Info and can be freely read by the user, removing the line from an internal buffer of Logger.

Definition at line 466 of file Logger.cpp.

std::string RTT::Logger::getLogModule (  )  const

Get the name of the current Log generating Module.

std::string RTT::Logger::getLogModule (  )  const

Get the name of the current Log generating Module.

Definition at line 398 of file Logger.cpp.

os::TimeService::ticks RTT::Logger::getReferenceTime (  )  const

Function to get the loggers starting timestamp

TimeService::ticks RTT::Logger::getReferenceTime (  )  const

Function to get the loggers starting timestamp

Definition at line 337 of file Logger.cpp.

Logger& RTT::Logger::in ( const std::string &  modname  ) 

Inform the Logger of the entry of a module.

See also:
In. Use Logger::In(modname) for management.
Logger & RTT::Logger::in ( const std::string &  modname  ) 

Inform the Logger of the entry of a module.

See also:
In. Use Logger::In(modname) for management.

Definition at line 384 of file Logger.cpp.

static Logger* RTT::Logger::Instance ( std::ostream &  str = std::cerr  )  [static]

Get the singleton logger.

Postcondition:
If the singleton did not already exist then it is created and associated with the given ostream. If the singleton already existed then no change occurs (and the singleton remains associated with its existing ostream).
Logger * RTT::Logger::Instance ( std::ostream &  str = std::cerr  )  [static]

Get the singleton logger.

Postcondition:
If the singleton did not already exist then it is created and associated with the given ostream. If the singleton already existed then no change occurs (and the singleton remains associated with its existing ostream).

Definition at line 72 of file Logger.cpp.

static Logger& RTT::Logger::log ( LogLevel  ll  )  [static]

As log(), but also specify the LogLevel of the next message.

static Logger& RTT::Logger::log (  )  [static]

As Instance(), but more userfriendly.

Logger & RTT::Logger::log ( LogLevel  ll  )  [static]

As log(), but also specify the LogLevel of the next message.

Definition at line 93 of file Logger.cpp.

Logger & RTT::Logger::log (  )  [static]

As Instance(), but more userfriendly.

Definition at line 89 of file Logger.cpp.

void RTT::Logger::logendl (  ) 

Add endl and flush buffers. Will always log at least one line.

void RTT::Logger::logendl (  ) 

Add endl and flush buffers. Will always log at least one line.

Definition at line 570 of file Logger.cpp.

void RTT::Logger::logflush (  ) 

Flush log buffers. May log nothing if empty.

void RTT::Logger::logflush (  ) 

Flush log buffers. May log nothing if empty.

Definition at line 540 of file Logger.cpp.

void RTT::Logger::lognl (  ) 

Add newline without flushing buffers. If you need to log a lot of lines, this is advised with a flush or endl at the end.

void RTT::Logger::lognl (  ) 

Add newline without flushing buffers. If you need to log a lot of lines, this is advised with a flush or endl at the end.

Definition at line 564 of file Logger.cpp.

bool RTT::Logger::mayLog (  )  const [private]

Returns true if the next message will be logged. Returns false if the LogLevel is RealTime and allowRealTime() was not called or if the logger was not started.

bool RTT::Logger::mayLog (  )  const [private]

Returns true if the next message will be logged. Returns false if the LogLevel is RealTime and allowRealTime() was not called or if the logger was not started.

Definition at line 308 of file Logger.cpp.

bool RTT::Logger::mayLogFile (  )  const [private]
void RTT::Logger::mayLogFile ( bool  tf  ) 

Toggles the flag if the logger may log to the file stream.

bool RTT::Logger::mayLogFile (  )  const [private]

Definition at line 312 of file Logger.cpp.

void RTT::Logger::mayLogFile ( bool  tf  ) 

Toggles the flag if the logger may log to the file stream.

Definition at line 324 of file Logger.cpp.

bool RTT::Logger::mayLogStdOut (  )  const [private]
void RTT::Logger::mayLogStdOut ( bool  tf  ) 

Toggles the flag if the logger may log to the standard output stream.

bool RTT::Logger::mayLogStdOut (  )  const [private]

Definition at line 316 of file Logger.cpp.

void RTT::Logger::mayLogStdOut ( bool  tf  ) 

Toggles the flag if the logger may log to the standard output stream.

Definition at line 320 of file Logger.cpp.

static std::ostream& RTT::Logger::nl ( std::ostream &  __os  )  [static]

Insert a newline '
' in the ostream. (Why is this not in the standard ?)

std::ostream & RTT::Logger::nl ( std::ostream &  __os  )  [static]

Insert a newline '
' in the ostream. (Why is this not in the standard ?)

Definition at line 343 of file Logger.cpp.

Logger& RTT::Logger::operator<< ( std::ostream &(*)(std::ostream &)  pf  ) 

Catch the std::endl and other stream manipulators.

Logger& RTT::Logger::operator<< ( const char *   ) 

Log a text message. This is equivalent to the templated operator<<, but reduces code size since it is compiled only once.

Logger& RTT::Logger::operator<< ( const std::string &   ) 

Log a string. This is equivalent to the templated operator<<, but reduces code size since it is compiled only once.

Logger& RTT::Logger::operator<< ( LogLevel  ll  ) 

Set the loglevel of the incomming messages.

template<class T >
Logger& RTT::Logger::operator<< ( t  )  [inline]

Send (user defined) data into this logger. All data with lower priority than the current loglevel will be discarded. If any loglevel (thus in or out) is set to Never, it will never be displayed. You must flush() or end with std::endl to get the log's output in your file or display.

Logger & RTT::Logger::operator<< ( std::ostream &(*)(std::ostream &)  pf  ) 

Catch the std::endl and other stream manipulators.

Definition at line 518 of file Logger.cpp.

Logger & RTT::Logger::operator<< ( const char *  t  ) 

Log a text message. This is equivalent to the templated operator<<, but reduces code size since it is compiled only once.

Definition at line 491 of file Logger.cpp.

Logger & RTT::Logger::operator<< ( const std::string &  t  ) 

Log a string. This is equivalent to the templated operator<<, but reduces code size since it is compiled only once.

Definition at line 507 of file Logger.cpp.

Logger & RTT::Logger::operator<< ( LogLevel  ll  ) 

Set the loglevel of the incomming messages.

Definition at line 511 of file Logger.cpp.

template<class T >
Logger& RTT::Logger::operator<< ( t  )  [inline]

Send (user defined) data into this logger. All data with lower priority than the current loglevel will be discarded. If any loglevel (thus in or out) is set to Never, it will never be displayed. You must flush() or end with std::endl to get the log's output in your file or display.

Logger& RTT::Logger::out ( const std::string &  modname  ) 

The counterpart of in().

See also:
In. Use Logger::In(modname) for management.
Logger & RTT::Logger::out ( const std::string &  modname  ) 

The counterpart of in().

See also:
In. Use Logger::In(modname) for management.

Definition at line 391 of file Logger.cpp.

static void RTT::Logger::Release (  )  [static]

Delete the singleton logger.

void RTT::Logger::Release (  )  [static]

Delete the singleton logger.

Definition at line 79 of file Logger.cpp.

void RTT::Logger::setLogLevel ( LogLevel  ll  ) 

Set the loglevel of the outgoing (streamed) messages. All messages with this level or higher importance will be displayed. For example, setting to Logger::Debug will print everyting, setting to Logger::Critical will only print critical or fatal errors.

void RTT::Logger::setLogLevel ( LogLevel  ll  ) 

Set the loglevel of the outgoing (streamed) messages. All messages with this level or higher importance will be displayed. For example, setting to Logger::Debug will print everyting, setting to Logger::Critical will only print critical or fatal errors.

Definition at line 576 of file Logger.cpp.

void RTT::Logger::setStdStream ( std::ostream &  stdos  ) 

Set the standard output stream. (default is cerr).

void RTT::Logger::setStdStream ( std::ostream &  stdos  ) 

Set the standard output stream. (default is cerr).

Definition at line 485 of file Logger.cpp.

void RTT::Logger::shutdown (  ) 

Print a 'goodbye' string in Info, Flush all streams and stop Logging.

void RTT::Logger::shutdown (  ) 

Print a 'goodbye' string in Info, Flush all streams and stop Logging.

Definition at line 458 of file Logger.cpp.

void RTT::Logger::startup (  ) 

Print a 'welcome' string in Info and reset log timestamp.

void RTT::Logger::startup (  ) 

Print a 'welcome' string in Info and reset log timestamp.

Definition at line 408 of file Logger.cpp.


Member Data Documentation

static Logger * RTT::Logger::_instance = 0 [static, private]

Definition at line 287 of file install/include/rtt/Logger.hpp.

D * RTT::Logger::d [private]

Definition at line 56 of file install/include/rtt/Logger.hpp.

std::ostream & RTT::Logger::fileline [private]

Definition at line 65 of file install/include/rtt/Logger.hpp.

These three are required to have a correct operator<<(T t) behavior for setting the stream formatting etc.

Definition at line 63 of file install/include/rtt/Logger.hpp.

std::ostream & RTT::Logger::logline [private]

Definition at line 64 of file install/include/rtt/Logger.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


rtt
Author(s): RTT Developers
autogenerated on Fri Jan 11 09:49:47 2013