Ceylan::Log::LogSource Class Reference

This is the mother class for every potential sender of Log messages. More...

#include <CeylanLogSource.h>

Inheritance diagram for Ceylan::Log::LogSource:

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

Collaboration graph
[legend]

List of all members.

Public Types

enum  TextOutputFormat { rawText, html }
 Defines what text output formats for TextDisplayable instances are available. More...

Public Member Functions

 LogSource (const std::string &name, LevelOfDetail levelOfDetail=DefaultLevelOfDetailForSource)
 Constructs a LogSource whose channel has for name name, with no registered LogTransport.
 LogSource (const std::string &name, LogTransport &transport, LevelOfDetail levelOfDetail=DefaultLevelOfDetailForSource)
 Constructs a LogSource whose channel has for name name, linked to specified LogTransport.
 LogSource (LogTransport &transport, LevelOfDetail levelOfDetail=DefaultLevelOfDetailForSource)
 Constructs a LogSource linked to specified LogTransport.
virtual ~LogSource () throw ()
 Basic virtual destructor.
bool hasChannelName () const
 Returns whether this Log source has a registered channel name.
void setChannelName (const std::string &channelName)
 Sets this LogSource channel name.
std::string getChannelName () const
 Returns this LogSource channel name.
void setLevelOfDetail (LevelOfDetail newLevel)
 Sets this LogSource level of detail of interest.
LevelOfDetail getLevelOfDetail () const
 Returns this LogSource channel name.
virtual void send (const std::string &message, LevelOfDetail levelOfDetail=DefaultLevelOfDetailForMessage)
 Sends message to this LogSource's internal channel, through known LogTransport.
virtual void sendToChannel (const std::string &channel, const std::string &message, LevelOfDetail levelOfDetail=DefaultLevelOfDetailForMessage) const
 Sends message to the specified channel, through known LogTransport.
virtual void setTransport (LogTransport &newTransport)
 Sets a new Log transport for this LogSource.
virtual LogTransportgetTransport () const
 Returns this LogSource's Log transport.
virtual bool hasTransport () const
 Tells whether this LogSource has a registered Log transport.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns a user-friendly description of the state of this object.

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 DefaultLevelOfDetailForSource = 10
 The default level of detail of a Log source.

Protected Member Functions

virtual void directSend (const std::string &channel, const std::string &message, LevelOfDetail levelOfDetail=DefaultLevelOfDetailForMessage) const
 Internal method to send messages.
virtual void unlinkTransport ()
 Suppresses the link between this LogSource and its Log transport.

Protected Attributes

std::string _channelName
 Stores this LogSource channel name.
LevelOfDetail _level
 The current level of detail of interest for this Log source.
LogTransport_transport
 The LogTransport to be used for sending messages.

Static Protected Attributes

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

Private Member Functions

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


Detailed Description

This is the mother class for every potential sender of Log messages.

Its job is to propagate incoming Log messages to the relevant LogListener, through a LogTransport.

Note:
The send methods, thanks to their parameters, create a log message object, whose ownership is transferred to the LogTransport, which is in charge of deallocating it when deemed appropriate.
See also:
Log, LogTransport

Definition at line 63 of file CeylanLogSource.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

LogSource::LogSource ( const std::string &  name,
LevelOfDetail  levelOfDetail = DefaultLevelOfDetailForSource 
) [explicit]

Constructs a LogSource whose channel has for name name, with no registered LogTransport.

See also:
setTransport

Definition at line 44 of file CeylanLogSource.cc.

LogSource::LogSource ( const std::string &  name,
LogTransport transport,
LevelOfDetail  levelOfDetail = DefaultLevelOfDetailForSource 
)

Constructs a LogSource whose channel has for name name, linked to specified LogTransport.

Definition at line 53 of file CeylanLogSource.cc.

LogSource::LogSource ( LogTransport transport,
LevelOfDetail  levelOfDetail = DefaultLevelOfDetailForSource 
) [explicit]

Constructs a LogSource linked to specified LogTransport.

Note:
setChannelName should be called before any message is sent from this LogSource's internal channel.

Definition at line 64 of file CeylanLogSource.cc.

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

Basic virtual destructor.

Definition at line 74 of file CeylanLogSource.cc.

References unlinkTransport().

Ceylan::Log::LogSource::LogSource ( const LogSource 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 LogSource::directSend ( const std::string &  channel,
const std::string &  message,
LevelOfDetail  levelOfDetail = DefaultLevelOfDetailForMessage 
) const [protected, virtual]

Internal method to send messages.

Filters them out if their level of detail is higher than the one of this log source.

Definition at line 164 of file CeylanLogSource.cc.

References _transport, and Ceylan::Log::LogTransport::propagate().

Referenced by send(), and sendToChannel().

std::string LogSource::getChannelName (  )  const

Returns this LogSource channel name.

Definition at line 101 of file CeylanLogSource.cc.

References _channelName.

Referenced by toString().

LevelOfDetail LogSource::getLevelOfDetail (  )  const

Returns this LogSource channel name.

Definition at line 119 of file CeylanLogSource.cc.

References _level.

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

LogTransport * LogSource::getTransport (  )  const [virtual]

Returns this LogSource's Log transport.

Definition at line 209 of file CeylanLogSource.cc.

References _transport.

bool LogSource::hasChannelName (  )  const

Returns whether this Log source has a registered channel name.

Definition at line 83 of file CeylanLogSource.cc.

References _channelName.

Referenced by toString().

bool LogSource::hasTransport (  )  const [virtual]

Tells whether this LogSource has a registered Log transport.

Definition at line 218 of file CeylanLogSource.cc.

References _transport.

Referenced by setTransport().

LogSource& Ceylan::Log::LogSource::operator= ( const LogSource 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 LogSource::send ( const std::string &  message,
LevelOfDetail  levelOfDetail = DefaultLevelOfDetailForMessage 
) [virtual]

Sends message to this LogSource's internal channel, through known LogTransport.

Parameters:
message the log message to send. Please avoid characters '<' and '>' since they have a special meaning for HTML log output. These characters used to be filtered in HTML aggregators but it prevented messages to contain HTML tags on purpose, which proved to be convenient.
levelOfDetail the level of detail of this message (level 1 by default).
Note:
This method cannot be const since it would do so with Ceylan::Object's one, which has to be non-const because of its possible need to forge an identifier and mutable is not used.
See also:
send with implied internal channel

Reimplemented in Ceylan::Object, and Ceylan::Log::MuteLogSource.

Definition at line 128 of file CeylanLogSource.cc.

References _channelName, and directSend().

Referenced by Ceylan::Log::LogPlug::CreateBasicPlug(), Ceylan::Log::LogPlug::debug(), Ceylan::Log::LogPlug::error(), Ceylan::Log::LogPlug::fatal(), Ceylan::Log::LogPlug::info(), Ceylan::Log::LogPlug::logroot(), Ceylan::Log::LogPlug::trace(), and Ceylan::Log::LogPlug::warning().

void LogSource::sendToChannel ( const std::string &  channel,
const std::string &  message,
LevelOfDetail  levelOfDetail = DefaultLevelOfDetailForMessage 
) const [virtual]

Sends message to the specified channel, through known LogTransport.

Note:
This method is to be used when a message is to be sent to a channel different from the LogSource's internal one.
Parameters:
channel the channel name which will identify the targeted Loglistener.
message the log message to send. Please avoid characters '<' and '>' since they have a special meaning for HTML log output. These characters used to be filtered in HTML aggregators but it prevented messages to contain HTML tags on purpose, which proved to be convenient.
levelOfDetail the level of detail of this message (level 1 by default).
See also:
send with implied internal channel

Definition at line 142 of file CeylanLogSource.cc.

References _level, CEYLAN_LOG, directSend(), and Ceylan::toString().

void LogSource::setChannelName ( const std::string &  channelName  ) 

Sets this LogSource channel name.

Reimplemented in Ceylan::Log::Loggable.

Definition at line 92 of file CeylanLogSource.cc.

References _channelName.

void LogSource::setLevelOfDetail ( LevelOfDetail  newLevel  ) 

Sets this LogSource level of detail of interest.

Definition at line 110 of file CeylanLogSource.cc.

References _level.

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 LogSource::setTransport ( LogTransport newTransport  )  [virtual]

Sets a new Log transport for this LogSource.

Definition at line 191 of file CeylanLogSource.cc.

References _transport, hasTransport(), unlinkTransport(), and Ceylan::Log::LogPlug::warning().

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 LogSource::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

Implements Ceylan::TextDisplayable.

Reimplemented in Ceylan::Object, Ceylan::Log::MuteLogSource, Ceylan::Maths::Random::RandomGenerator, Ceylan::Maths::Random::RandomGeneratorFromPDF, Ceylan::Maths::Random::WhiteNoiseGenerator, Ceylan::Module, and Ceylan::Plugin.

Definition at line 227 of file CeylanLogSource.cc.

References _level, getChannelName(), hasChannelName(), and Ceylan::toNumericalString().

Referenced by Ceylan::Log::LogPlug::ToString().

void LogSource::unlinkTransport (  )  [protected, virtual]

Suppresses the link between this LogSource and its Log transport.

Definition at line 243 of file CeylanLogSource.cc.

Referenced by setTransport(), and ~LogSource().


Member Data Documentation

std::string Ceylan::Log::LogSource::_channelName [protected]

Stores this LogSource channel name.

Definition at line 242 of file CeylanLogSource.h.

Referenced by getChannelName(), hasChannelName(), send(), and setChannelName().

The current level of detail of interest for this Log source.

Definition at line 246 of file CeylanLogSource.h.

Referenced by getLevelOfDetail(), sendToChannel(), setLevelOfDetail(), 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 LogTransport to be used for sending messages.

Definition at line 258 of file CeylanLogSource.h.

Referenced by directSend(), getTransport(), hasTransport(), and setTransport().

The default level of detail of a Log source.

Definition at line 221 of file CeylanLogSource.h.


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

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