LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst::pex::logging::DualLog Class Reference

a Log that sends message to both the screen and a file. More...

#include <DualLog.h>

Inheritance diagram for lsst::pex::logging::DualLog:
lsst::pex::logging::ScreenLog lsst::pex::logging::Log

Public Member Functions

 DualLog (const lsst::daf::base::PropertySet &preamble, const std::string &filename, int filethresh=0, int screenthresh=0, bool screenVerbose=false)
 
 DualLog (const std::string &filename, int filethresh=0, int screenthresh=0, bool screenVerbose=false)
 
 DualLog (const DualLog &that)
 
virtual ~DualLog ()
 
DualLogoperator= (const DualLog &that)
 
int getFileThreshold ()
 
void setFileThreshold (int thresh)
 
- Public Member Functions inherited from lsst::pex::logging::ScreenLog
 ScreenLog (bool verbose=false, int threshold=Log::INFO)
 
 ScreenLog (const lsst::daf::base::PropertySet &preamble, bool verbose=false, int threshold=Log::INFO)
 
 ScreenLog (const ScreenLog &that)
 
virtual ~ScreenLog ()
 
ScreenLogoperator= (const ScreenLog &that)
 
int getScreenThreshold ()
 
void setScreenThreshold (int thresh)
 
void setScreenVerbose (bool printAll)
 
bool isScreenVerbose ()
 
- Public Member Functions inherited from lsst::pex::logging::Log
 Log (const int threshold=INFO, const std::string &name="")
 
 Log (const std::list< boost::shared_ptr< LogDestination > > &destinations, const lsst::daf::base::PropertySet &preamble, const std::string &name="", const int threshold=INFO, bool defaultShowAll=false)
 
 Log (const Log &parent, const std::string &childName, int threshold=INHERIT_THRESHOLD)
 
 Log (const Log &that)
 
virtual ~Log ()
 
Logoperator= (const Log &that)
 
const std::string & getName () const
 
int getThreshold () const
 
void setThreshold (int threshold)
 
bool sends (int importance) const
 
void resetThreshold ()
 
void setThresholdFor (const std::string &name, int threshold)
 
int getThresholdFor (const std::string &name) const
 
bool willShowAll () const
 
void setShowAll (bool yesno)
 
void resetShowAll ()
 
template<class T >
void addPreambleProperty (const std::string &name, const T &val)
 
template<class T >
void setPreambleProperty (const std::string &name, const T &val)
 
LogcreateChildLog (const std::string &childName, int threshold=INHERIT_THRESHOLD) const
 
void log (int importance, const std::string &message, const lsst::daf::base::PropertySet &properties)
 
template<class T >
void log (int importance, const std::string &message, const std::string &name, const T &val)
 
template<class T >
void log (int importance, const std::string &message, const RecordProperty< T > &prop)
 
void log (int importance, const std::string &message)
 
void log (int importance, const boost::format &message)
 
void logdebug (const std::string &message, const lsst::daf::base::PropertySet &properties)
 
template<class T >
void logdebug (const std::string &message, const std::string &name, const T &val)
 
template<class T >
void logdebug (const std::string &message, const RecordProperty< T > &prop)
 
void logdebug (const std::string &message)
 
void logdebug (const boost::format &message)
 
void info (const std::string &message, const lsst::daf::base::PropertySet &properties)
 
template<class T >
void info (const std::string &message, const std::string &name, const T &val)
 
template<class T >
void info (const std::string &message, const RecordProperty< T > &prop)
 
void info (const std::string &message)
 
void info (const boost::format &message)
 
void warn (const std::string &message, const lsst::daf::base::PropertySet &properties)
 
template<class T >
void warn (const std::string &message, const std::string &name, const T &val)
 
template<class T >
void warn (const std::string &message, const RecordProperty< T > &prop)
 
void warn (const std::string &message)
 
void warn (const boost::format &message)
 
void fatal (const std::string &message, const lsst::daf::base::PropertySet &properties)
 
template<class T >
void fatal (const std::string &message, const std::string &name, const T &val)
 
template<class T >
void fatal (const std::string &message, const RecordProperty< T > &prop)
 
void fatal (const std::string &message)
 
void fatal (const boost::format &message)
 
void format (int importance, const char *fmt,...)
 
void debugf (const char *fmt,...)
 
void infof (const char *fmt,...)
 
void warnf (const char *fmt,...)
 
void fatalf (const char *fmt,...)
 
void send (const LogRecord &record)
 
void addDestination (std::ostream &destination, int threshold)
 
void addDestination (std::ostream &destination, int threshold, const boost::shared_ptr< LogFormatter > &formatter)
 
void addDestination (const boost::shared_ptr< LogDestination > &destination)
 
const
lsst::daf::base::PropertySet
getPreamble ()
 
void markPersistent ()
 
void printThresholds (std::ostream &out)
 
void reset ()
 

Static Public Member Functions

static void createDefaultLog (const lsst::daf::base::PropertySet &preamble, const std::string &filename, int filethresh=Log::INHERIT_THRESHOLD, int screenthresh=0, bool screenVerbose=false)
 
static void createDefaultLog (const std::string &filename, int filethresh=Log::INHERIT_THRESHOLD, int screenthresh=0, bool screenVerbose=false)
 
- Static Public Member Functions inherited from lsst::pex::logging::ScreenLog
static void createDefaultLog (bool verbose=false, int threshold=Log::INFO)
 
static void createDefaultLog (const lsst::daf::base::PropertySet &preamble, bool verbose=false, int threshold=Log::INFO)
 
- Static Public Member Functions inherited from lsst::pex::logging::Log
static LoggetDefaultLog ()
 
static void createDefaultLog (const std::list< boost::shared_ptr< LogDestination > > &destinations, const lsst::daf::base::PropertySet &preamble, const std::string &name="", const int threshold=INFO)
 
static void closeDefaultLog ()
 

Private Member Functions

void _init (const std::string &filename, int filethresh)
 

Private Attributes

LogDestination_file
 
std::ofstream * fstrm
 

Additional Inherited Members

- Static Public Attributes inherited from lsst::pex::logging::Log
static const int DEBUG
 
static const int INFO
 
static const int WARN
 
static const int INHERIT_THRESHOLD
 
static const int FATAL
 
- Protected Member Functions inherited from lsst::pex::logging::Log
void _send (int threshold, int importance, const char *fmt, va_list ap)
 
void _format (int importance, const char *fmt, va_list ap)
 
- Static Protected Member Functions inherited from lsst::pex::logging::Log
static void setDefaultLog (Log *deflog)
 
- Protected Attributes inherited from lsst::pex::logging::Log
boost::shared_ptr
< threshold::Memory
_thresholds
 
std::list< boost::shared_ptr
< LogDestination > > 
_destinations
 
lsst::daf::base::PropertySet::Ptr _preamble
 
- Static Protected Attributes inherited from lsst::pex::logging::Log
static LogdefaultLog
 
static const std::string _sep
 

Detailed Description

a Log that sends message to both the screen and a file.

This class uses the BriefFormatter for printing to the screen (via cout) and the NetLoggerFormatter for the file. This class provides an interface for controlling the amount printed to the screen (setPrintAllProps()) as well as the thresholds on the individual destinations.

Definition at line 49 of file DualLog.h.

Constructor & Destructor Documentation

lsst::pex::logging::DualLog::DualLog ( const lsst::daf::base::PropertySet preamble,
const std::string &  filename,
int  filethresh = 0,
int  screenthresh = 0,
bool  screenVerbose = false 
)

create a Log that will write messages to a given file

Parameters
preamblea list of data properties that should be included with every recorded message to the Log. This constructor will automatically add a property ("LOG") giving the Log name.
filenamethe name of the file to send messages to. It will be opened in append mode.
filethreshthe importance threshold to set for the log file
screenthreshthe importance threshold to set for messages going to the screen.
screenVerboseif true, all message data properties will be printed to the screen. If false, only the Log name ("LOG") and the text comment ("COMMENT") will be printed.
lsst::pex::logging::DualLog::DualLog ( const std::string &  filename,
int  filethresh = 0,
int  screenthresh = 0,
bool  screenVerbose = false 
)

create a Log that will write messages to a given file

Parameters
filenamethe name of the file to send messages to. It will be opened in append mode.
filethreshthe importance threshold to set for the log file
screenthreshthe importance threshold to set for messages going to the screen.
screenVerboseif true, all message data properties will be printed to the screen. If false, only the Log name ("LOG") and the text comment ("COMMENT") will be printed.
lsst::pex::logging::DualLog::DualLog ( const DualLog that)
inline

create a copy

Definition at line 90 of file DualLog.h.

91  : ScreenLog(that), _file(that._file)
92  { }
ScreenLog(bool verbose=false, int threshold=Log::INFO)
LogDestination * _file
Definition: DualLog.h:162
virtual lsst::pex::logging::DualLog::~DualLog ( )
virtual

delete this log

Member Function Documentation

void lsst::pex::logging::DualLog::_init ( const std::string &  filename,
int  filethresh 
)
private
static void lsst::pex::logging::DualLog::createDefaultLog ( const lsst::daf::base::PropertySet preamble,
const std::string &  filename,
int  filethresh = Log::INHERIT_THRESHOLD,
int  screenthresh = 0,
bool  screenVerbose = false 
)
static

create a new log and set it as the default Log

Parameters
preamblea list of data properties that should be included with every recorded message to the Log. This constructor will automatically add a property ("LOG") giving the Log name.
filenamethe name of the file to send messages to. It will be opened in append mode.
filethreshthe importance threshold to set for the log file
screenthreshthe importance threshold to set for messages going to the screen.
screenVerboseif true, all message data properties will be printed to the screen. If false, only the Log name ("LOG") and the text comment ("COMMENT") will be printed.
static void lsst::pex::logging::DualLog::createDefaultLog ( const std::string &  filename,
int  filethresh = Log::INHERIT_THRESHOLD,
int  screenthresh = 0,
bool  screenVerbose = false 
)
static

create a new log and set it as the default Log

Parameters
filenamethe name of the file to send messages to. It will be opened in append mode.
filethreshthe importance threshold to set for the log file
screenthreshthe importance threshold to set for messages going to the screen.
screenVerboseif true, all message data properties will be printed to the screen. If false, only the Log name ("LOG") and the text comment ("COMMENT") will be printed.
int lsst::pex::logging::DualLog::getFileThreshold ( )
inline

return the importance threshold current set for the log file. This applies only to the file stream set at construction time.

Definition at line 113 of file DualLog.h.

113 { return _file->getThreshold(); }
LogDestination * _file
Definition: DualLog.h:162
DualLog& lsst::pex::logging::DualLog::operator= ( const DualLog that)
inline

copy another one into this

Definition at line 102 of file DualLog.h.

102  {
103  if (this == &that) return *this;
104  dynamic_cast<ScreenLog*>(this)->operator=(that);
105  _file = that._file;
106  return *this;
107  }
ScreenLog(bool verbose=false, int threshold=Log::INFO)
LogDestination * _file
Definition: DualLog.h:162
void lsst::pex::logging::DualLog::setFileThreshold ( int  thresh)
inline

set the importance threshold current set for the log file. This only affects the file stream set at construction time; other subsequently added streams are unaffected.

Definition at line 120 of file DualLog.h.

120 { _file->setThreshold(thresh); }
LogDestination * _file
Definition: DualLog.h:162

Member Data Documentation

LogDestination* lsst::pex::logging::DualLog::_file
private

Definition at line 162 of file DualLog.h.

std::ofstream* lsst::pex::logging::DualLog::fstrm
private

Definition at line 163 of file DualLog.h.


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