Ceylan::Log::LogAggregatorConsole Class Reference

This class implements the LogAggregator interface thanks to console-based direct output, hence with no file being written. More...

#include <CeylanLogAggregatorConsole.h>

Inheritance diagram for Ceylan::Log::LogAggregatorConsole:

Inheritance graph
[legend]
Collaboration diagram for Ceylan::Log::LogAggregatorConsole:

Collaboration graph
[legend]

List of all members.

Public Types

enum  StandardStream { Output, Error, Log }
 Describes the three standard streams :
  • Output is the standard output stream, which is the default standard stream being used
  • Error is the standard error stream
  • Log is the standard log stream.
More...

Public Member Functions

 LogAggregatorConsole (StandardStream consoleStream=LogAggregatorConsole::Output, bool immediateWrite=true, bool useGlobalLevelOfDetail=true, bool beSmart=true)
 Constructs a LogAggregatorConsole which will output incoming log messages in console-based output.
virtual ~LogAggregatorConsole () throw ()
 Virtual destructor.
virtual void aggregate ()
 Aggregates all channel and log messages informations in the console.
virtual void store (LogMessage &message)
 Classify and stores message internally, according to the corresponding channels they contain.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns a user-friendly description of the state of this object.
virtual LogChannelcreateBasicChannel (const std::string &channelName)
 Creates, if possible, a new basic channel whose name is channelName.
virtual ObjectChannelcreateObjectChannel (LogMessage &message)
 Creates, if possible, a new object channel corresponding to the specified Loggable message.
virtual bool hasChannel (const std::string &channelName) const
 Tells whether this aggregator has already a channel named channelName.
virtual LogChannelfindChannel (const std::string &channelName) const
 Finds, if any, a channel in LogAggregator's list of channels whose name is channelName.
virtual void transferChannel (LogChannel &source, LogChannel &target)
 Transfers all the messages of source into target, updates their channel identifier so that it matches the one of target.
virtual void removeChannel (LogChannel &target)
 Removes completly a log channel.

Static Public Member Functions

static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.

Static Public Attributes

static const LevelOfDetail DefaultGlobalLevelOfDetail = Ceylan::Log::DefaultLevelOfDetailForListener
 Default value for the aggregator-wide level of detail.

Protected Member Functions

virtual void write (const LogChannel &channel) const
 Internal method used to perform the effective output of log channels on the console.
virtual void write (const LogMessage &message) const
 Internal method used to perform the effective writing of log messages on the console.
virtual LogChannelfindBasicChannel (const std::string &basicChannelName) const
 Finds, if any, a Log channel in LogAggregator's list of channels whose name is channelName.
virtual ObjectChannelfindObjectChannel (const std::string &nonPrefixedChannelName) const
 Finds, if any, an Object channel in LogAggregator's list of object channels whose short name is channelName (no protocol prefix or separator allowed).
virtual void createBasicChannelFrom (LogMessage &message)
 Creates a basic (non protocol-prefixed) channel from specified message, which is automatically added to this new channel.
virtual void createLoggableChannelFrom (LogMessage &message)
 Creates a Loggable channel from specified message.
virtual void storeBasicMessage (LogMessage &basicLogMessage)
 Classify and stores basic log message basicLogMessage internally, according to the corresponding channel it contains.
virtual void storeObjectMessage (LogMessage &objectLogMessage)
 Classify and stores object log message objectLogMessage internally, according to the corresponding channel it contains.
virtual void demangle (LogMessage &objectLogMessage)
 Corrects, if possible, any mangled class name in specified message.
virtual Ceylan::VerbosityLevels getOverallVerbosityLevel () const
 Returns the most appropriate level of detail for log channel output, depending only on the state of the aggregator.
virtual Ceylan::VerbosityLevels getMessageVerbosityLevel (const LogMessage &message) const
 Returns the most appropriate level of detail for log message output, depending on the state of the aggregator and on the message's level of detail.

Static Protected Member Functions

static Ceylan::VerbosityLevels ConvertListenerLevelOfDetailToVerbosityLevel (LevelOfDetail level)
 Converts a level of detail of a log listener into a corresponding verbosity level.
static Ceylan::VerbosityLevels ConvertMessageLevelOfDetailToVerbosityLevel (LevelOfDetail level)
 Converts a level of detail of a log message into a corresponding verbosity level.

Protected Attributes

StandardStream _streamNumber
 The identifier of the standard steam being used.
std::ostream * _outputStream
 The output stream where log messages should be written.
System::Console_console
 The text console, used on embedded devices (ex: the Nintendo DS) instead of an output stream.
bool _immediateWrite
 Tells whether log messages should be written to log file as soon as they are received.
bool _useGlobalLevelOfDetail
 Tells whether a global (aggregator-wide) level of detail for channels should be used.
LevelOfDetail _globalLevelOfDetail
 Defines the aggregator-wide level of detail, used if _useGlobalLevelOfDetail is set.
std::list< LogChannel * > _channelList
 List of all known Log channels.
bool _beSmart
 Tells whether this aggregator should cope with mangled class names.

Static Protected Attributes

static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.

Private Member Functions

 LogAggregatorConsole (const LogAggregatorConsole &source)
 Copy constructor made private to ensure that it will be never called.
LogAggregatorConsoleoperator= (const LogAggregatorConsole &source)
 Assignment operator made private to ensure that it will be never called.


Detailed Description

This class implements the LogAggregator interface thanks to console-based direct output, hence with no file being written.

Note:
This is the simpliest log aggregator, useful whenever the Ceylan library is built with no file descriptor support.
Log messages are stored in chronological order (based on the time they were received, not on their respective timestamp), all in a row, each prefixed by its channel name.

See also:
LogAggregator

Definition at line 79 of file CeylanLogAggregatorConsole.h.


Member Enumeration Documentation

Describes the three standard streams :

  • Output is the standard output stream, which is the default standard stream being used
  • Error is the standard error stream
  • Log is the standard log stream.

The difference between Log and Error is that Log is buffered wheread Error is not.

Enumerator:
Output 
Error 
Log 

Definition at line 97 of file CeylanLogAggregatorConsole.h.

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

LogAggregatorConsole::LogAggregatorConsole ( StandardStream  consoleStream = LogAggregatorConsole::Output,
bool  immediateWrite = true,
bool  useGlobalLevelOfDetail = true,
bool  beSmart = true 
) [explicit]

Constructs a LogAggregatorConsole which will output incoming log messages in console-based output.

The logs are stored with a raw encoding, as opposed to HTML encoding for example.

Parameters:
consoleStream tells to which standard stream logs should be written. The default is the standard output stream, Output. On the Nintendo DS, a Ceylan text console will be used instead of a C++ output stream.
immediateWrite tells whether the aggregator should write log messages as soon as they are received (the safe and default behaviour).
useGlobalLevelOfDetail tells whether log channels levels of detail are to be overriden by the aggregator-wide one.
beSmart tells whether this aggregator should be smart and auto-correct messages with faulty classnames.
Exceptions:
LogAggregatorException if the operation fails.

Definition at line 71 of file CeylanLogAggregatorConsole.cc.

References _console, _immediateWrite, _outputStream, Error, Log, Output, and Ceylan::System::Console::setToForeground().

LogAggregatorConsole::~LogAggregatorConsole (  )  throw () [virtual]

Virtual destructor.

Note:
If this aggregator has been set to be smart, it will automatically trigger log aggregation upon deletion.

Definition at line 123 of file CeylanLogAggregatorConsole.cc.

References Ceylan::Log::LogAggregator::_beSmart, _console, Ceylan::System::Console::addInBuffer(), aggregate(), Ceylan::System::Console::blankBuffer(), CEYLAN_LOG, Ceylan::display(), dataUtils::e, Ceylan::System::Console::goInteractive(), and Ceylan::Exception::toString().

Ceylan::Log::LogAggregatorConsole::LogAggregatorConsole ( const LogAggregatorConsole source  )  [private]

Copy constructor made private to ensure that it will be never called.

The compiler should complain whenever this undefined constructor is called, implicitly or not.


Member Function Documentation

void LogAggregatorConsole::aggregate (  )  [virtual]

Aggregates all channel and log messages informations in the console.

Exceptions:
LogAggregatorException if the operation fails.
Note:
this method does nothing if the immediate write flag is turned on : work should be already done.

Implements Ceylan::Log::LogAggregator.

Definition at line 183 of file CeylanLogAggregatorConsole.cc.

References Ceylan::Log::LogAggregator::_channelList, _immediateWrite, CEYLAN_LOG, and Ceylan::Timestamp::toString().

Referenced by ~LogAggregatorConsole().

Ceylan::VerbosityLevels LogAggregator::ConvertListenerLevelOfDetailToVerbosityLevel ( LevelOfDetail  level  )  [static, protected, inherited]

Converts a level of detail of a log listener into a corresponding verbosity level.

Definition at line 824 of file CeylanLogAggregator.cc.

References Ceylan::Log::DefaultLevelOfDetailForListener, Ceylan::high, Ceylan::low, Ceylan::Log::MaximumLevelOfDetailForListener, and Ceylan::medium.

Referenced by Ceylan::Log::LogAggregator::getOverallVerbosityLevel().

Ceylan::VerbosityLevels LogAggregator::ConvertMessageLevelOfDetailToVerbosityLevel ( LevelOfDetail  level  )  [static, protected, inherited]

Converts a level of detail of a log message into a corresponding verbosity level.

Definition at line 856 of file CeylanLogAggregator.cc.

References Ceylan::Log::DefaultLevelOfDetailForMessage, Ceylan::high, Ceylan::low, Ceylan::Log::MaximumLevelOfDetailForMessage, and Ceylan::medium.

Referenced by Ceylan::Log::LogAggregator::getMessageVerbosityLevel().

LogChannel & LogAggregator::createBasicChannel ( const std::string &  channelName  )  [virtual, inherited]

Creates, if possible, a new basic channel whose name is channelName.

Definition at line 120 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogAggregator::_channelList, CEYLAN_LOG, and Ceylan::Log::LogAggregator::hasChannel().

Referenced by Ceylan::Log::LogAggregator::createBasicChannelFrom().

void LogAggregator::createBasicChannelFrom ( LogMessage message  )  [protected, virtual, inherited]

Creates a basic (non protocol-prefixed) channel from specified message, which is automatically added to this new channel.

Definition at line 397 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogChannel::addMessage(), Ceylan::Log::LogAggregator::createBasicChannel(), and Ceylan::Log::LogMessage::getChannelName().

Referenced by Ceylan::Log::LogAggregator::createLoggableChannelFrom(), and Ceylan::Log::LogAggregator::storeBasicMessage().

void LogAggregator::createLoggableChannelFrom ( LogMessage message  )  [protected, virtual, inherited]

Creates a Loggable channel from specified message.

Parameters:
message the incoming Loggable message which triggers this channel creation.
Note:
If the incoming message that would lead to create a channel A has the same address as past events which led to the creation of a channel B, then all the messages in B will be transferred into a newly created channel A, no matter A and B. If messages are sent from destructors, then the channel will be finally renamed as the base class, and not the specialized class being effectively used. So sending messages from destructors should be avoided.

Definition at line 413 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogAggregator::_beSmart, Ceylan::Log::LogAggregator::_channelList, Ceylan::Log::ObjectChannel::addMessage(), CEYLAN_LOG, Ceylan::Log::LogAggregator::createBasicChannelFrom(), Ceylan::Log::LogAggregator::createObjectChannel(), Ceylan::Log::ObjectIdentifier::differentButMatches(), Ceylan::Log::ObjectIdentifier::generateFromChannelName(), Ceylan::Log::LogMessage::getChannelName(), Ceylan::Log::Loggable::GetEmbeddedChannelName(), Ceylan::Exception::toString(), and Ceylan::Log::LogAggregator::transferChannel().

Referenced by Ceylan::Log::LogAggregator::storeObjectMessage().

ObjectChannel & LogAggregator::createObjectChannel ( LogMessage message  )  [virtual, inherited]

void LogAggregator::demangle ( LogMessage objectLogMessage  )  [protected, virtual, inherited]

LogChannel * LogAggregator::findBasicChannel ( const std::string &  basicChannelName  )  const [protected, virtual, inherited]

Finds, if any, a Log channel in LogAggregator's list of channels whose name is channelName.

Returns:
the basic channel, if found, otherwise a null pointer.
Note:
this method is dedicated to find basic log channels, not object ones.

Definition at line 302 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogAggregator::_channelList, and CEYLAN_LOG.

Referenced by Ceylan::Log::LogAggregator::findChannel(), and Ceylan::Log::LogAggregator::storeBasicMessage().

LogChannel * LogAggregator::findChannel ( const std::string &  channelName  )  const [virtual, inherited]

Finds, if any, a channel in LogAggregator's list of channels whose name is channelName.

Returns:
the channel, if found, otherwise a null pointer.
Note:
if the specified channel name is an object channel name (typically starting by 'loggable://'), search will be only performed on object channels.

Definition at line 181 of file CeylanLogAggregator.cc.

References CEYLAN_LOG, Ceylan::Log::LogAggregator::findBasicChannel(), Ceylan::Log::LogAggregator::findObjectChannel(), Ceylan::Log::Loggable::GetEmbeddedChannelName(), and Ceylan::Log::Loggable::IsALoggableChannelName().

Referenced by Ceylan::Log::LogAggregator::hasChannel().

ObjectChannel * LogAggregator::findObjectChannel ( const std::string &  nonPrefixedChannelName  )  const [protected, virtual, inherited]

Finds, if any, an Object channel in LogAggregator's list of object channels whose short name is channelName (no protocol prefix or separator allowed).

Returns:
the object channel, if found, otherwise a null pointer.
Note:
this method is dedicated to find object log channels, not basic ones.

Definition at line 349 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogAggregator::_channelList, CEYLAN_LOG, and Ceylan::Log::LogChannel::getName().

Referenced by Ceylan::Log::LogAggregator::findChannel(), and Ceylan::Log::LogAggregator::storeObjectMessage().

Ceylan::VerbosityLevels LogAggregator::getMessageVerbosityLevel ( const LogMessage message  )  const [protected, virtual, inherited]

Returns the most appropriate level of detail for log message output, depending on the state of the aggregator and on the message's level of detail.

Basically, maps a global or local level of detail to a verbosity level.

Definition at line 790 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogAggregator::_globalLevelOfDetail, Ceylan::Log::LogAggregator::_useGlobalLevelOfDetail, CEYLAN_LOG, Ceylan::Log::LogAggregator::ConvertMessageLevelOfDetailToVerbosityLevel(), Ceylan::Log::LogMessage::getLevelOfDetail(), and Ceylan::toString().

Referenced by Ceylan::Log::LogAggregatorRaw::write(), and write().

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]

Ceylan::VerbosityLevels LogAggregator::getOverallVerbosityLevel (  )  const [protected, virtual, inherited]

Returns the most appropriate level of detail for log channel output, depending only on the state of the aggregator.

Basically, maps a global or local level of detail to a verbosity level.

Definition at line 760 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogAggregator::_globalLevelOfDetail, Ceylan::Log::LogAggregator::_useGlobalLevelOfDetail, CEYLAN_LOG, Ceylan::Log::LogAggregator::ConvertListenerLevelOfDetailToVerbosityLevel(), Ceylan::Log::DefaultLevelOfDetailForListener, and Ceylan::toString().

Referenced by Ceylan::Log::LogAggregatorRaw::write(), and write().

bool LogAggregator::hasChannel ( const std::string &  channelName  )  const [virtual, inherited]

Tells whether this aggregator has already a channel named channelName.

Exceptions:
LogException if an inconsistency is detected in channel list.

Definition at line 171 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogAggregator::findChannel().

Referenced by Ceylan::Log::LogAggregator::createBasicChannel(), and Ceylan::Log::LogAggregator::createObjectChannel().

LogAggregatorConsole& Ceylan::Log::LogAggregatorConsole::operator= ( const LogAggregatorConsole source  )  [private]

Assignment operator made private to ensure that it will be never called.

The compiler should complain whenever this undefined operator is called, implicitly or not.

void LogAggregator::removeChannel ( LogChannel target  )  [virtual, inherited]

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

void LogAggregatorConsole::store ( LogMessage message  )  [virtual]

Classify and stores message internally, according to the corresponding channels they contain.

Note:
this implementation, if immediateWrite mode was selected, will immediatly output this message on the console.
Parameters:
message the log message to be stored, the aggregator takes ownership of it.
Exceptions:
LogException if the operation fails.

Reimplemented from Ceylan::Log::LogAggregator.

Definition at line 236 of file CeylanLogAggregatorConsole.cc.

References _immediateWrite, CEYLAN_LOG, Ceylan::Log::LogMessage::toString(), and write().

void LogAggregator::storeBasicMessage ( LogMessage basicLogMessage  )  [protected, virtual, inherited]

Classify and stores basic log message basicLogMessage internally, according to the corresponding channel it contains.

Parameters:
message the basic log message to be stored, the aggregator takes ownership of it.

Definition at line 597 of file CeylanLogAggregator.cc.

References CEYLAN_LOG, Ceylan::Log::LogAggregator::createBasicChannelFrom(), Ceylan::Log::LogAggregator::findBasicChannel(), and Ceylan::Log::LogMessage::getChannelName().

Referenced by Ceylan::Log::LogAggregator::store().

void LogAggregator::storeObjectMessage ( LogMessage objectLogMessage  )  [protected, virtual, inherited]

Classify and stores object log message objectLogMessage internally, according to the corresponding channel it contains.

Parameters:
objectLogMessage the object log message to be stored, the aggregator takes ownership of it.

Definition at line 628 of file CeylanLogAggregator.cc.

References Ceylan::Log::ObjectChannel::addMessage(), CEYLAN_LOG, Ceylan::Log::LogAggregator::createLoggableChannelFrom(), Ceylan::Log::LogAggregator::demangle(), Ceylan::Log::LogAggregator::findObjectChannel(), Ceylan::Log::LogMessage::getChannelName(), Ceylan::Log::Loggable::GetEmbeddedChannelName(), and Ceylan::Log::LogMessage::setChannelName().

Referenced by Ceylan::Log::LogAggregator::store().

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const string LogAggregatorConsole::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]

Returns a user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
TextDisplayable

Reimplemented from Ceylan::Log::LogAggregator.

Definition at line 328 of file CeylanLogAggregatorConsole.cc.

References _immediateWrite, _streamNumber, _useGlobalLevelOfDetail, Error, Log, and Output.

void LogAggregator::transferChannel ( LogChannel source,
LogChannel target 
) [virtual, inherited]

Transfers all the messages of source into target, updates their channel identifier so that it matches the one of target.

This method helps correcting wrong channel names due to mangled class names.

Note:
As the ownership of transferred message is transferred to the target channel, the source message pointers are set to null so that, when source channel will be deallocated, messages will not be touched.

Definition at line 204 of file CeylanLogAggregator.cc.

References Ceylan::Log::LogChannel::_messages, Ceylan::Log::LogChannel::addMessage(), CEYLAN_LOG, Ceylan::Log::LogChannel::getName(), Ceylan::low, Ceylan::Log::LogAggregator::removeChannel(), Ceylan::Log::LogMessage::setChannelName(), Ceylan::Log::LogMessage::toString(), and Ceylan::Log::LogChannel::toString().

Referenced by Ceylan::Log::LogAggregator::createLoggableChannelFrom().

void LogAggregatorConsole::write ( const LogMessage message  )  const [protected, virtual]

Internal method used to perform the effective writing of log messages on the console.

Parameters:
message the log message to write
Note:
this method is mainly used when immediate writing mode is set.

Definition at line 307 of file CeylanLogAggregatorConsole.cc.

References _console, Ceylan::System::Console::addInBuffer(), CEYLAN_LOG, Ceylan::Log::LogAggregator::getMessageVerbosityLevel(), and Ceylan::Log::LogMessage::toString().

void LogAggregatorConsole::write ( const LogChannel channel  )  const [protected, virtual]

Internal method used to perform the effective output of log channels on the console.

Parameters:
channel the log channel to output on the console.
Exceptions:
LogException if the operation fails.

Definition at line 286 of file CeylanLogAggregatorConsole.cc.

References _console, Ceylan::System::Console::addInBuffer(), CEYLAN_LOG, Ceylan::Log::LogAggregator::getOverallVerbosityLevel(), and Ceylan::Log::LogChannel::toString().

Referenced by store().


Member Data Documentation

bool Ceylan::Log::LogAggregator::_beSmart [protected, inherited]

std::list<LogChannel *> Ceylan::Log::LogAggregator::_channelList [protected, inherited]

The text console, used on embedded devices (ex: the Nintendo DS) instead of an output stream.

Definition at line 239 of file CeylanLogAggregatorConsole.h.

Referenced by LogAggregatorConsole(), write(), and ~LogAggregatorConsole().

Defines the aggregator-wide level of detail, used if _useGlobalLevelOfDetail is set.

Reimplemented from Ceylan::Log::LogAggregator.

Definition at line 265 of file CeylanLogAggregatorConsole.h.

Tells whether log messages should be written to log file as soon as they are received.

Definition at line 247 of file CeylanLogAggregatorConsole.h.

Referenced by aggregate(), LogAggregatorConsole(), store(), and toString().

TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().

The output stream where log messages should be written.

Definition at line 231 of file CeylanLogAggregatorConsole.h.

Referenced by LogAggregatorConsole().

The identifier of the standard steam being used.

Definition at line 224 of file CeylanLogAggregatorConsole.h.

Referenced by toString().

Tells whether a global (aggregator-wide) level of detail for channels should be used.

Note:
if set, will override log channels levels of details.

Reimplemented from Ceylan::Log::LogAggregator.

Definition at line 257 of file CeylanLogAggregatorConsole.h.

Referenced by toString().

Default value for the aggregator-wide level of detail.

Reimplemented in Ceylan::Log::LogAggregatorHTML.

Definition at line 247 of file CeylanLogAggregator.h.


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

Generated on Thu Jun 4 20:40:24 2009 for Ceylan by  doxygen 1.5.8