LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
lsst::pex::harness::TracingLog Class Reference

#include <TracingLog.h>

Inheritance diagram for lsst::pex::harness::TracingLog:
lsst::pex::logging::Log

Public Member Functions

 TracingLog (const logging::Log &parent, const std::string &name, int tracelev=TracingLog::TRACE, const std::string &funcName="")
 
 TracingLog (const TracingLog &that)
 
TracingLogoperator= (const TracingLog &that)
 
TracingLogcreateForTraceBlock (const std::string &name, int tracelev=logging::Log::INHERIT_THRESHOLD, const std::string &funcName="")
 
TracingLogtraceBlock (const std::string &name, int tracelev=logging::Log::INHERIT_THRESHOLD, const std::string &funcName="")
 
virtual ~TracingLog ()
 
void start ()
 
void start (const std::string &funcName)
 
void done ()
 
int getTraceLevel () const
 
const std::string & getFunctionName () const
 
- 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 Attributes

static const int TRACE = logging::Log::INFO - 1
 
static const std::string STATUS
 
static const std::string START
 
static const std::string END
 
- 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
 

Private Attributes

int _tracelev
 
std::string _funcName
 

Additional Inherited Members

- 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 ()
 
- 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 specialized Log that assists the harness in tracing execution flow.

The motivation for this class is to provide uniformity in the log messages that indicate the start and finish of some section of code. This makes it easier to locate these records after execution and calculate the time spent in the traced code.

Definition at line 50 of file TracingLog.h.

Constructor & Destructor Documentation

lsst::pex::harness::TracingLog::TracingLog ( const logging::Log parent,
const std::string &  name,
int  tracelev = TracingLog::TRACE,
const std::string &  funcName = "" 
)

construct a TracingLog.

Parameters
parentthe parent log to inherit attributes from
namethe name to give the log relative to its parent
tracelevthe default level to use for the tracing messages
funcNamethe name of the block of code (e.g. function) being traced. If empty, the value given by name will be used instead. This value will be used in the log message only.

Definition at line 45 of file TracingLog.cc.

47  : Log(parent, name), _tracelev(tracelev), _funcName(funcName)
48 {
49  if (_funcName.length() == 0) _funcName = name;
51  const TracingLog *p = dynamic_cast<const TracingLog*>(&parent);
52  if (p) {
53  _tracelev = p->getTraceLevel();
54  }
55  else {
56  _tracelev = TRACE;
57  }
58  }
59 }
TracingLog(const logging::Log &parent, const std::string &name, int tracelev=TracingLog::TRACE, const std::string &funcName="")
Definition: TracingLog.cc:45
static const int INHERIT_THRESHOLD
Definition: Log.h:183
Log(const int threshold=INFO, const std::string &name="")
lsst::pex::harness::TracingLog::TracingLog ( const TracingLog that)
inline

create a copy of a TracingLog

Definition at line 92 of file TracingLog.h.

93  : Log(*this), _tracelev(that._tracelev), _funcName(that._funcName)
94  { }
Log(const int threshold=INFO, const std::string &name="")
lsst::pex::harness::TracingLog::~TracingLog ( )
virtual

delete the log

Definition at line 61 of file TracingLog.cc.

61 { }

Member Function Documentation

TracingLog* lsst::pex::harness::TracingLog::createForTraceBlock ( const std::string &  name,
int  tracelev = logging::Log::INHERIT_THRESHOLD,
const std::string &  funcName = "" 
)
inline

create and return a new child that should be used while tracing a function. A "start" message will be logged to the new log as part of the call. Like createChildLog(), the caller is responsible for deleting this new instance when finished with it.

Parameters
namethe name to give the log relative to its parent
tracelevthe default level to use for the tracing messages. If equal to Log::INHERIT_THRESHOLD (default), it will be set to this log's tracing level.
funcNamethe name of the block of code (e.g. function) being traced. If empty, the value given by name will be used instead. This value will be used in the log message only.

Definition at line 120 of file TracingLog.h.

123  {
124  TracingLog *out = new TracingLog(*this, name, tracelev, funcName);
125  // out->setShowAll(true);
126  out->start();
127  return out;
128  }
TracingLog(const logging::Log &parent, const std::string &name, int tracelev=TracingLog::TRACE, const std::string &funcName="")
Definition: TracingLog.cc:45
void lsst::pex::harness::TracingLog::done ( )
inline

Indicate that the section of code being traced (e.g. a function body) is finished.

Definition at line 170 of file TracingLog.h.

170  {
171  if (sends(_tracelev)) {
172  std::string msg("Ending ");
173  msg += _funcName;
174  log(_tracelev, msg, STATUS, END);
175  }
176  }
static const std::string END
Definition: TracingLog.h:73
void log(int importance, const std::string &message, const lsst::daf::base::PropertySet &properties)
static const std::string STATUS
Definition: TracingLog.h:61
bool sends(int importance) const
Definition: Log.h:302
const std::string& lsst::pex::harness::TracingLog::getFunctionName ( ) const
inline

return the name of the code block being traced which will appear in the start and end messages.

Definition at line 188 of file TracingLog.h.

188 { return _funcName; }
int lsst::pex::harness::TracingLog::getTraceLevel ( ) const
inline

return the tracing message level, the importance to be given to the start and end messages.

Definition at line 182 of file TracingLog.h.

182 { return _tracelev; }
TracingLog& lsst::pex::harness::TracingLog::operator= ( const TracingLog that)
inline

reset this instance to another

Definition at line 99 of file TracingLog.h.

99  {
100  Log::operator=(that);
101  _tracelev = that._tracelev;
102  _funcName = that._funcName;
103  return *this;
104  }
Log & operator=(const Log &that)
void lsst::pex::harness::TracingLog::start ( )
inline

Indicate that the section of code being traced (e.g. a function body) is starting.

Definition at line 149 of file TracingLog.h.

149  {
150  if (sends(_tracelev)) {
151  std::string msg("Starting ");
152  msg += _funcName;
153  log(_tracelev, msg, STATUS, START);
154  }
155  }
static const std::string START
Definition: TracingLog.h:67
void log(int importance, const std::string &message, const lsst::daf::base::PropertySet &properties)
static const std::string STATUS
Definition: TracingLog.h:61
bool sends(int importance) const
Definition: Log.h:302
void lsst::pex::harness::TracingLog::start ( const std::string &  funcName)
inline

Indicate that the section of code being traced (e.g. a function body) is starting.

Definition at line 161 of file TracingLog.h.

161  {
162  if (funcName.length() > 0) _funcName = funcName;
163  start();
164  }
TracingLog* lsst::pex::harness::TracingLog::traceBlock ( const std::string &  name,
int  tracelev = logging::Log::INHERIT_THRESHOLD,
const std::string &  funcName = "" 
)
inline

a synonym for createForTraceBlock

Definition at line 133 of file TracingLog.h.

136  {
137  return createForTraceBlock(name, tracelev, funcName);
138  }
TracingLog * createForTraceBlock(const std::string &name, int tracelev=logging::Log::INHERIT_THRESHOLD, const std::string &funcName="")
Definition: TracingLog.h:120

Member Data Documentation

std::string lsst::pex::harness::TracingLog::_funcName
private

Definition at line 192 of file TracingLog.h.

int lsst::pex::harness::TracingLog::_tracelev
private

Definition at line 191 of file TracingLog.h.

const std::string lsst::pex::harness::TracingLog::END
static

the property to use to mark the start of a block of code being traced

Definition at line 73 of file TracingLog.h.

const std::string lsst::pex::harness::TracingLog::START
static

the property to use to mark the start of a block of code being traced

Definition at line 67 of file TracingLog.h.

const std::string lsst::pex::harness::TracingLog::STATUS
static

the property name that will indicate what a trace message is marking

Definition at line 61 of file TracingLog.h.

const int lsst::pex::harness::TracingLog::TRACE = logging::Log::INFO - 1
static

default message level for messages that trace execution flow

Definition at line 56 of file TracingLog.h.


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