libmoost
moost::logging::global Class Reference

Initialise the global logging API. More...

#include <global.hpp>

Collaboration diagram for moost::logging::global:

List of all members.

Public Member Functions

bool is_enabled () const
 Check if the logging framework is enabled.
bool is_configured () const
 Check if the logging framework has been configured yet.
bool enable ()
 Use default basic configuration.
bool enable (boost::filesystem::path const &filepath, bool use_default=false)
 Use default basic configuration.
bool enable (std::string const &filepath, bool use_default=false)
 Use process name.
void disable ()
 Disables the logging framework.
void attach_ostream (std::ostream &out)
 Attach an ostream.
void detach_ostream ()
 Detach the ostream.
pseudo_ostreamget_ostream ()
 Get a reference to the global pseudo ostream.

Private Member Functions

 global ()
bool set_enabled (bool enabled)

Private Attributes

bool enabled_
pseudo_ostream out_

Friends

class moost::utils::singleton_default< T >::friend_type

Detailed Description

Initialise the global logging API.

This class is designed to be a singleton and represents a single point of entry into the initialisation API of the logging framework. Before you can make use of the logging framework you must 'enable' it using one of the enable methods. Once the framework has been enabled there is no additional need to access the global singleton unless you wish to either disable it again or change some of the logging options.

An ostream reference can also be assigned to the global singleton, which will be used to output any status/error information.

Definition at line 84 of file global.hpp.


Constructor & Destructor Documentation

moost::logging::global::global ( ) [inline, private]

Definition at line 89 of file global.hpp.

Here is the call graph for this function:


Member Function Documentation

void moost::logging::global::attach_ostream ( std::ostream &  out) [inline]

Attach an ostream.

If this is set logging debug information will be sent to this stream.

Note:
Output to the stream will be protected by a mutex so there is no need to take any additional steps to prevent race conditions on the stream.

Once the ostream is assigned it MUST remain available for the lifetime of the logger or until 'detatch_ostream' is called. It shall be the responsibility of the consuming application to ensure this is the case.

Parameters:
outstd::ostream reference

Definition at line 284 of file global.hpp.

Here is the caller graph for this function:

Detach the ostream.

Once called the status/debug ostream associated with the logging framework will be detached and no longer used. After this call it is safe to destroy the ostream.

Definition at line 296 of file global.hpp.

Disables the logging framework.

Note:
Once this has been called the logging framework is then considered configured but not enabled.

Definition at line 257 of file global.hpp.

Here is the caller graph for this function:

bool moost::logging::global::enable ( ) [inline]

Use default basic configuration.

Returns:
True if logging was successfully enabled

Definition at line 130 of file global.hpp.

Here is the caller graph for this function:

bool moost::logging::global::enable ( boost::filesystem::path const &  filepath,
bool  use_default = false 
) [inline]

Use default basic configuration.

Will use the program name and search got logging config, if that can't be found it will either use the default basic configuration or leave configuration in a disabled state.

Parameters:
filepathto a config file
use_defaultif config cannot be found
Returns:
True if logging was successfully enabled

Definition at line 154 of file global.hpp.

bool moost::logging::global::enable ( std::string const &  filepath,
bool  use_default = false 
) [inline]

Use process name.

Will use the program name and search got logging config, if that can't be found it will either use the default basic configuration or leave configuration in a disabled state.

Note:
It is permissiable to pass the full path to the program name, which is normally the format provided by argv[0]. In this case the program name will be extracted and used.
Parameters:
filepathto the current program
use_defaultif config cannot be found
Returns:
True if logging was successfully enabled

Definition at line 194 of file global.hpp.

Get a reference to the global pseudo ostream.

Returns:
pseudo ostream reference

Definition at line 306 of file global.hpp.

bool moost::logging::global::is_configured ( ) const [inline]

Check if the logging framework has been configured yet.

This differs from is_enabled in so far as the framework may very well be configured but not actually enabled.

Returns:
True/False

Definition at line 119 of file global.hpp.

bool moost::logging::global::is_enabled ( ) const [inline]

Check if the logging framework is enabled.

This differs from is_configured in so far as the framework may very well be configured but not actually enabled.

Returns:
True/False

Definition at line 106 of file global.hpp.

bool moost::logging::global::set_enabled ( bool  enabled) [inline, private]

Definition at line 312 of file global.hpp.


Friends And Related Function Documentation

friend class moost::utils::singleton_default< T >::friend_type [friend]

Definition at line 86 of file global.hpp.


Member Data Documentation

Definition at line 327 of file global.hpp.

Definition at line 328 of file global.hpp.


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