0.12.0
Freundlich's C++ toolkit
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions
fcppt::log::object Class Reference

Detailed Description

The main logger class.

This class represents a logger object, encapsulating a level stream for every log level, a formatter for the logger itself and which log levels are activated. You should create one logger object for each subsystem you wish to enable or disable logging for.

Public Member Functions

 object (fcppt::log::parameters::object const &parameters)
 Constructs a logger object.
 
 ~object ()
 Destroys a logger object.
 
void log (fcppt::log::level::type level, fcppt::log::detail::temporary_output const &output)
 Logs a message.
 
fcppt::log::level_streamlevel_sink (fcppt::log::level::type level)
 The level stream corresponding to a log level.
 
fcppt::log::level_stream const & level_sink (fcppt::log::level::type level) const
 The level stream corresponding to a log level.
 
void activate (fcppt::log::level::type level)
 Activates a log level.
 
void deactivate (fcppt::log::level::type level)
 Deactivates a log level.
 
bool activated (fcppt::log::level::type level) const
 Returns if a level is activated.
 
bool enabled_and_activated (fcppt::log::level::type level) const
 Returns if a level is activated and the logger is enabled.
 
void enable (bool enabled)
 Sets the logger's enabled state.
 
bool enabled () const
 Returns if the logger is enabled.
 
fcppt::log::format::function
const & 
formatter () const
 Returns the associated formatter.
 
fcppt::log::level_stream_array
const & 
level_streams () const
 Returns the associated level streams.
 
fcppt::log::enabled_level_array
const & 
enabled_levels () const
 Returns which levels are enabled.
 
fcppt::log::optional_location const location () const
 Returns the location if any.
 

Constructor & Destructor Documentation

fcppt::log::object::object ( fcppt::log::parameters::object const &  parameters)
explicit

Constructs a logger object.

Constructs a logger object given the parameters parameters

fcppt::log::object::~object ( )

Destroys a logger object.

It is important the logger object is destroyed before its context is destroyed, if it has one.

Member Function Documentation

void fcppt::log::object::activate ( fcppt::log::level::type  level)

Activates a log level.

Activates the log level given by level

Parameters
levelThe log level to activate
Warning
The behaviour is undefined if level is fcppt::log::level::size
bool fcppt::log::object::activated ( fcppt::log::level::type  level) const

Returns if a level is activated.

Returns if level is activated.

Parameters
levelThe log level to query the activated state for
Warning
The behaviour is undefined if level is fcppt::log::level::size
void fcppt::log::object::deactivate ( fcppt::log::level::type  level)

Deactivates a log level.

Deactivates the log level given by level

Parameters
levelThe log level to deactivate
Warning
The behaviour is undefined if level is fcppt::log::level::size
void fcppt::log::object::enable ( bool  enabled)

Sets the logger's enabled state.

Sets the logger's enabled state to enabled

Parameters
enabledThe new enabled state
bool fcppt::log::object::enabled ( ) const

Returns if the logger is enabled.

bool fcppt::log::object::enabled_and_activated ( fcppt::log::level::type  level) const

Returns if a level is activated and the logger is enabled.

Returns if level is activated and the logger is enabled. Equivalent to activated(level) && enabled().

Parameters
levelThe log level to query the activated state for
Warning
The behaviour is undefined if level is fcppt::log::level::size
fcppt::log::enabled_level_array const& fcppt::log::object::enabled_levels ( ) const

Returns which levels are enabled.

fcppt::log::format::function const& fcppt::log::object::formatter ( ) const

Returns the associated formatter.

fcppt::log::level_stream& fcppt::log::object::level_sink ( fcppt::log::level::type  level)

The level stream corresponding to a log level.

Returns the level stream corresponding to level.

Parameters
levelThe log level to get the level stream for
Warning
The behaviour is undefined if level is fcppt::log::level::size
fcppt::log::level_stream const& fcppt::log::object::level_sink ( fcppt::log::level::type  level) const

The level stream corresponding to a log level.

Returns the level stream corresponding to level.

Parameters
levelThe log level to get the level stream for
Warning
The behaviour is undefined if level is fcppt::log::level::size
fcppt::log::level_stream_array const& fcppt::log::object::level_streams ( ) const

Returns the associated level streams.

fcppt::log::optional_location const fcppt::log::object::location ( ) const

Returns the location if any.

Returns
Returns the loggers location if it has any or fcppt::log::optional_location()
void fcppt::log::object::log ( fcppt::log::level::type  level,
fcppt::log::detail::temporary_output const &  output 
)

Logs a message.

Logs a message given by output to level level. If enabled_and_activated(level) is false, nothing will be logged. An output can be constructed from fcppt::log::_.

Parameters
levelThe log level to log to
outputThe output to log
Note
You are advised not to use this element function directly, because creating an output even if the logger will discard it can be significant overhead. Instead, use the macros FCPPT_LOG_DEBUG and so on directly.
Warning
The behaviour is undefined if level is fcppt::log::level::size