bes Updated for version 3.20.13
BESLog Class Reference

Provides a mechanism for applications to log information to an external file. More...

#include <BESLog.h>

Collaboration diagram for BESLog:
Collaboration graph

Public Types

typedef std::ios &(* p_ios_manipulator) (std::ios &)
 Defines a data type p_ios_manipulator "pointer to function that takes ios& and returns ios&".
 
typedef std::ostream &(* p_ostream_manipulator) (std::ostream &)
 Defines a data type p_std::ostream_manipulator "pointer to function that takes std::ostream& and returns std::ostream&".
 

Public Member Functions

virtual void dump (std::ostream &strm) const
 dumps information about this object
 
virtual void flush_me ()
 
std::ostream * get_log_ostream ()
 
bool is_verbose ()
 Returns true if verbose logging is requested.
 
BESLogoperator<< (char *)
 Overloaded inserter that writes the specified char *.
 
BESLogoperator<< (char)
 Overloaded inserter that writes the specified char value.
 
BESLogoperator<< (const char *)
 Overloaded inserter that writes the specified const char *.
 
BESLogoperator<< (const std::string &)
 Overloaded inserter that writes the specified const string.
 
BESLogoperator<< (double)
 Overloaded inserter that writes the specified double value.
 
BESLogoperator<< (int)
 Overloaded inserter that writes the specified int value.
 
BESLogoperator<< (long)
 Overloaded inserter that writes the specified long value.
 
BESLogoperator<< (p_ios_manipulator)
 Overloaded inserter that takes ios methods.
 
BESLogoperator<< (p_ostream_manipulator)
 Overloaded inserter that takes stream manipulation methods.
 
BESLogoperator<< (std::string &)
 Overloaded inserter that writes the specified string.
 
BESLogoperator<< (unsigned int)
 
BESLogoperator<< (unsigned long)
 Overloaded inserter that writes the specified unsigned long value.
 
void resume ()
 Resumes logging after being suspended.
 
void suspend ()
 Suspend logging of any information until resumed.
 
void verbose_off ()
 turns off verbose logging
 
void verbose_on ()
 turn on verbose logging
 
 ~BESLog ()
 Cleans up the logging mechanism.
 

Static Public Member Functions

static BESLogTheLog ()
 

Static Public Attributes

static const std::string mark = string("|&|")
 

Protected Member Functions

 BESLog ()
 constructor that sets up logging for the application.
 
void dump_time ()
 Protected method that dumps the date/time to the log file.
 

Detailed Description

Provides a mechanism for applications to log information to an external file.

BESLog provides a mechanism for applications to log information to an external file, such as debugging information. This file is defined in the BESKeys mechanism using the key BES.LogName.

Also provides a mechanism to define whether debugging information should be verbose or not using the BESKeys key/value pair BES.LogVerbose.

Logging can also be suspended and resumed using so named methods.

BESLog is used similar to cerr and cout using the overloaded operator <<.

if( BESLog::TheLog()->is_verbose() )
{
    *(BESLog::TheLog()) << "This is some information to be logged"
                  << endl ;
}

Types of data that can be logged include:

  • std::string
  • char *
  • const char *
  • int
  • char
  • long
  • unsigned long
  • double
  • stream manipulators endl, ends and flush
  • ios manipulators hex, oct, dec

BESLog provides a static method for access to a single BESLog object, TheLog.

See also
TheBESKeys

Definition at line 130 of file BESLog.h.

Member Typedef Documentation

◆ p_ios_manipulator

typedef std::ios &(* BESLog::p_ios_manipulator) (std::ios &)

Defines a data type p_ios_manipulator "pointer to function that takes ios& and returns ios&".

Definition at line 220 of file BESLog.h.

◆ p_ostream_manipulator

typedef std::ostream &(* BESLog::p_ostream_manipulator) (std::ostream &)

Defines a data type p_std::ostream_manipulator "pointer to function that takes std::ostream& and returns std::ostream&".

Definition at line 222 of file BESLog.h.

Constructor & Destructor Documentation

◆ BESLog()

BESLog::BESLog ( )
protected

constructor that sets up logging for the application.

Sets up logging for the application by opening up the logging file and determining verbose logging.

The file name is determined using the BESKeys mechanism. The key used is BES.LogName. The application must be able to write to this directory/file.

Verbose logging is determined also using the BESKeys mechanism. The key used is BES.LogVerbose.

By default, log using UTC. BES.LogTimeLocal=yes will switch to using local time. Times are recorded in IOS8601.

Exceptions
BESInternalErrorif BESLogName is not set or if there are problems opening or writing to the log file.
See also
BESKeys

Definition at line 78 of file BESLog.cc.

◆ ~BESLog()

BESLog::~BESLog ( )

Cleans up the logging mechanism.

Cleans up the logging mechanism by closing the log file.

Definition at line 153 of file BESLog.cc.

Member Function Documentation

◆ dump()

void BESLog::dump ( std::ostream &  strm) const
virtual

dumps information about this object

Displays the pointer value of this instance along with information about the log file

Parameters
strmC++ i/o stream to dump the information to

Implements BESObj.

Definition at line 382 of file BESLog.cc.

◆ dump_time()

void BESLog::dump_time ( )
protected

Protected method that dumps the date/time to the log file.

Depending on the compile-time constant ISO8601_TIME_IN_LOGS, the time is dumped to the log file in the format: "MDT Thu Sep 9 11:05:16 2004", or in ISO8601 format: "YYYY-MM-DDTHH:MM:SS zone"

Definition at line 167 of file BESLog.cc.

◆ flush_me()

void BESLog::flush_me ( )
virtual

Definition at line 358 of file BESLog.cc.

◆ get_log_ostream()

std::ostream * BESLog::get_log_ostream ( )
inline

Definition at line 247 of file BESLog.h.

◆ is_verbose()

bool BESLog::is_verbose ( )
inline

Returns true if verbose logging is requested.

This method returns true if verbose logging has been requested either by setting the BESKeys key/value pair BES.LogVerbose=value or by turning on verbose logging using the method verbose_on.

If BES.LogVerbose is set to Yes, YES, or yes then verbose logging is turned on. If set to anything else then verbose logging is not turned on.

Returns
true if verbose logging has been requested.
See also
verbose_on
verbose_off
BESKeys

Definition at line 214 of file BESLog.h.

◆ operator<<() [1/12]

BESLog & BESLog::operator<< ( char *  val)

Overloaded inserter that writes the specified char *.

Parameters
valchar * to write to the log file

Definition at line 237 of file BESLog.cc.

◆ operator<<() [2/12]

BESLog & BESLog::operator<< ( char  val)

Overloaded inserter that writes the specified char value.

Parameters
valchar value to write to the log file

Definition at line 294 of file BESLog.cc.

◆ operator<<() [3/12]

BESLog & BESLog::operator<< ( const char *  val)

Overloaded inserter that writes the specified const char *.

Parameters
valconst char * to write to the log file

Definition at line 253 of file BESLog.cc.

◆ operator<<() [4/12]

BESLog & BESLog::operator<< ( const std::string &  s)

Overloaded inserter that writes the specified const string.

Parameters
sconst string to write to the log file

Definition at line 224 of file BESLog.cc.

◆ operator<<() [5/12]

BESLog & BESLog::operator<< ( double  val)

Overloaded inserter that writes the specified double value.

Parameters
valdouble value to write to the log file

Definition at line 333 of file BESLog.cc.

◆ operator<<() [6/12]

BESLog & BESLog::operator<< ( int  val)

Overloaded inserter that writes the specified int value.

Parameters
valint value to write to the log file

Definition at line 271 of file BESLog.cc.

◆ operator<<() [7/12]

BESLog & BESLog::operator<< ( long  val)

Overloaded inserter that writes the specified long value.

Parameters
vallong value to write to the log file

Definition at line 307 of file BESLog.cc.

◆ operator<<() [8/12]

BESLog & BESLog::operator<< ( p_ios_manipulator  val)

Overloaded inserter that takes ios methods.

Overloaded inserter that can take the address oct, dec and hex functions. This inserter is based on p_ios_manipulator, therefore the C++ standard functions oct, dec and hex can be applied to objects of the class BESLog.

Definition at line 369 of file BESLog.cc.

◆ operator<<() [9/12]

BESLog & BESLog::operator<< ( p_ostream_manipulator  val)

Overloaded inserter that takes stream manipulation methods.

Overloaded inserter that can take the address of endl, flush and ends functions. This inserter is based on p_ostream_manipulator, therefore the C++ standard functions for I/O endl, flush, and ends can be applied to objects of the class BESLog.

Definition at line 349 of file BESLog.cc.

◆ operator<<() [10/12]

BESLog & BESLog::operator<< ( std::string &  s)

Overloaded inserter that writes the specified string.

Todo:
Decide if this is really necessary.
Parameters
sstring to write to the log file

Definition at line 211 of file BESLog.cc.

◆ operator<<() [11/12]

BESLog & BESLog::operator<< ( unsigned int  val)

Definition at line 280 of file BESLog.cc.

◆ operator<<() [12/12]

BESLog & BESLog::operator<< ( unsigned long  val)

Overloaded inserter that writes the specified unsigned long value.

Parameters
valunsigned long value to write to the log file

Definition at line 320 of file BESLog.cc.

◆ resume()

void BESLog::resume ( )
inline

Resumes logging after being suspended.

This method resumes logging after suspended by the user. If logging was not already suspended this method does nothing.

Definition at line 173 of file BESLog.h.

◆ suspend()

void BESLog::suspend ( )
inline

Suspend logging of any information until resumed.

This method suspends any logging of information. If already suspended then nothing changes, logging is still suspended.

Definition at line 163 of file BESLog.h.

◆ TheLog()

BESLog * BESLog::TheLog ( )
static

Definition at line 400 of file BESLog.cc.

◆ verbose_off()

void BESLog::verbose_off ( )
inline

turns off verbose logging

This methods turns off verbose logging. If verbose logging was not already turned on then nothing changes.

Definition at line 194 of file BESLog.h.

◆ verbose_on()

void BESLog::verbose_on ( )
inline

turn on verbose logging

This method turns on verbose logging, providing applications the ability to log more detailed debugging information. If verbose is already turned on then nothing is changed.

Definition at line 184 of file BESLog.h.

Member Data Documentation

◆ mark

const string BESLog::mark = string("|&|")
static

Definition at line 156 of file BESLog.h.


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