LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lsst::pex::logging::LogRecord Class Reference

a container for constructing a single Log record More...

#include <LogRecord.h>

Inheritance diagram for lsst::pex::logging::LogRecord:
lsst::pex::logging::LogRec

Public Member Functions

 LogRecord (int threshold, int importance, bool showAll=false)
 
 LogRecord (int threshold, int importance, const lsst::daf::base::PropertySet &preamble, bool showAll=false)
 
 LogRecord (const LogRecord &that)
 
virtual ~LogRecord ()
 
LogRecordoperator= (const LogRecord &that)
 
void addComment (const std::string &comment)
 
void addComment (const boost::format &comment)
 
template<class T >
void addProperty (const RecordProperty< T > &property)
 
template<class T >
void addProperty (const std::string &name, const T &val)
 
void addProperties (const lsst::daf::base::PropertySet &props)
 
void addProperties (const lsst::daf::base::PropertySet::Ptr &props)
 
const
lsst::daf::base::PropertySet
getProperties () const
 
lsst::daf::base::PropertySetgetProperties ()
 
const
lsst::daf::base::PropertySet
data () const
 
lsst::daf::base::PropertySetdata ()
 
size_t countParamNames ()
 
size_t countParamValues () const
 
int getImportance () const
 
bool willRecord () const
 
bool willShowAll () const
 
void setShowAll (bool yesno)
 
void setTimestamp ()
 
virtual void setDate ()
 

Static Public Member Functions

static long long utcnow ()
 

Protected Member Functions

 LogRecord ()
 
void _init ()
 

Protected Attributes

bool _send
 
bool _showAll
 
int _vol
 
lsst::daf::base::PropertySet::Ptr _data
 

Detailed Description

a container for constructing a single Log record

The purpose of this class is to collect data for inclusion in a message to a Log.

Definition at line 99 of file LogRecord.h.

Constructor & Destructor Documentation

lsst::pex::logging::LogRecord::LogRecord ( int  threshold,
int  importance,
bool  showAll = false 
)

Create a log record to be sent to a given log. The current time is recorded and set as the DATE property.

Parameters
thresholdthe importance threshold that determines if a message is printed.
importancethe loudness of the record. If this value is greater than or equal to the given importance threshold, the message will be recorded.
showAllif true, prefer showing all properties when rendering this record. The default is false. (See willShow().)
lsst::pex::logging::LogRecord::LogRecord ( int  threshold,
int  importance,
const lsst::daf::base::PropertySet preamble,
bool  showAll = false 
)

Create a log record to be sent to a given log. The current time is recorded and set as the DATE property.

Parameters
thresholdthe importance threshold that determines if a message is printed.
importancethe loudness of the record. If this value is greater than or equal to the given importance threshold, the message will be recorded.
preamblean ordered set of properties that constitute the preamble of this message. This should not include the current time.
showAllif true, prefer showing all properties when rendering this record. The default is false. (See willShowAll().)
lsst::pex::logging::LogRecord::LogRecord ( const LogRecord that)
inline

create a copy of a record

Definition at line 137 of file LogRecord.h.

138  : _send(that._send), _showAll(that._showAll), _vol(that._vol), _data()
139  {
140  _data = that._data->deepCopy();
141  }
lsst::daf::base::PropertySet::Ptr _data
Definition: LogRecord.h:323
virtual lsst::pex::logging::LogRecord::~LogRecord ( )
virtual

delete this log record

lsst::pex::logging::LogRecord::LogRecord ( )
inlineprotected

Definition at line 308 of file LogRecord.h.

308 : _send(false), _vol(10), _data(new lsst::daf::base::PropertySet()) { }
lsst::daf::base::PropertySet::Ptr _data
Definition: LogRecord.h:323
Class for storing generic metadata.
Definition: PropertySet.h:82

Member Function Documentation

void lsst::pex::logging::LogRecord::_init ( )
inlineprotected

initialize this record with the DATE and LEVEL properties

Definition at line 313 of file LogRecord.h.

313  {
314  if (_send) {
315  _data->set("LEVEL", _vol);
316  setDate();
317  }
318  }
lsst::daf::base::PropertySet::Ptr _data
Definition: LogRecord.h:323
void lsst::pex::logging::LogRecord::addComment ( const std::string &  comment)
inline

add a string comment to this record. The comment will get stored in the data property under the key name, "COMMENT". The comment will only get added when willRecord() is returns true which is set when the record is constructed (usually by a Log object).

Definition at line 165 of file LogRecord.h.

165  {
166  if (_send) _data->add(LSST_LP_COMMENT, comment);
167  }
lsst::daf::base::PropertySet::Ptr _data
Definition: LogRecord.h:323
#define LSST_LP_COMMENT
Definition: LogRecord.h:40
void lsst::pex::logging::LogRecord::addComment ( const boost::format &  comment)
inline

add a string comment to this record. This version is provided as a convenience and is equivalent to addComment(comment.str()).

Definition at line 173 of file LogRecord.h.

173  {
174  if (_send) addComment(comment.str());
175  }
void addComment(const std::string &comment)
Definition: LogRecord.h:165
void lsst::pex::logging::LogRecord::addProperties ( const lsst::daf::base::PropertySet props)

add all of the properties found in the given PropertySet. This will make sure not to overwrite critical properties, LEVEL, LOG, TIMESTAMP, and DATE.

void lsst::pex::logging::LogRecord::addProperties ( const lsst::daf::base::PropertySet::Ptr props)
inline

add all of the properties found in the given PropertySet. This will make sure not to overwrite critical properties, LEVEL, LOG, TIMESTAMP, and DATE.

Definition at line 201 of file LogRecord.h.

201  {
202  addProperties(*props);
203  }
void addProperties(const lsst::daf::base::PropertySet &props)
template<class T >
void lsst::pex::logging::LogRecord::addProperty ( const RecordProperty< T > &  property)

attach a named item of data to this record.

Definition at line 327 of file LogRecord.h.

327  {
328  if (_send) property.addTo(_data);
329 }
lsst::daf::base::PropertySet::Ptr _data
Definition: LogRecord.h:323
template<class T >
void lsst::pex::logging::LogRecord::addProperty ( const std::string &  name,
const T &  val 
)

attach a named item of data to this record.

Definition at line 332 of file LogRecord.h.

332  {
333  if (_send) data().add(name, val);
334 }
table::Key< std::string > name
Definition: ApCorrMap.cc:71
const lsst::daf::base::PropertySet & data() const
Definition: LogRecord.h:221
bool val
void add(std::string const &name, T const &value)
Definition: PropertySet.cc:619
size_t lsst::pex::logging::LogRecord::countParamNames ( )
inline

return the number available property parameter names (i.e. ones that return non-PropertySet values).

Definition at line 233 of file LogRecord.h.

233  {
234  std::vector<std::string> names = data().paramNames(false);
235  return names.size();
236  }
std::vector< std::string > paramNames(bool topLevelOnly=true) const
Definition: PropertySet.cc:142
const lsst::daf::base::PropertySet & data() const
Definition: LogRecord.h:221
size_t lsst::pex::logging::LogRecord::countParamValues ( ) const

return the total number of data property values currently contained in this log record. This function will sum the number values associated with a name, summed over all available names (including subproperties). This total does not include PropertySet values.

const lsst::daf::base::PropertySet& lsst::pex::logging::LogRecord::data ( ) const
inline

return the data properties that make up this log message. This is a synonym for getProperties().

Definition at line 221 of file LogRecord.h.

221 { return *_data; }
lsst::daf::base::PropertySet::Ptr _data
Definition: LogRecord.h:323
lsst::daf::base::PropertySet& lsst::pex::logging::LogRecord::data ( )
inline

return the data properties that make up this log message. This is a synonym for getProperties().

Definition at line 227 of file LogRecord.h.

227 { return *_data; }
lsst::daf::base::PropertySet::Ptr _data
Definition: LogRecord.h:323
int lsst::pex::logging::LogRecord::getImportance ( ) const
inline

return the importance level–a measure of "loudness"–associated with this record.

Definition at line 250 of file LogRecord.h.

250 { return _vol; }
const lsst::daf::base::PropertySet& lsst::pex::logging::LogRecord::getProperties ( ) const
inline

return the read-only data properties that make up this log message. This is a synonym for data().

Definition at line 209 of file LogRecord.h.

209 { return data(); }
const lsst::daf::base::PropertySet & data() const
Definition: LogRecord.h:221
lsst::daf::base::PropertySet& lsst::pex::logging::LogRecord::getProperties ( )
inline

return the data properties that make up this log message. This is a synonym for data().

Definition at line 215 of file LogRecord.h.

215 { return data(); }
const lsst::daf::base::PropertySet & data() const
Definition: LogRecord.h:221
LogRecord& lsst::pex::logging::LogRecord::operator= ( const LogRecord that)
inline

copy another record into this one.

Definition at line 151 of file LogRecord.h.

151  {
152  _send = that._send;
153  _showAll = that._showAll;
154  _vol = that._vol;
155  _data = that._data;
156  return *this;
157  }
lsst::daf::base::PropertySet::Ptr _data
Definition: LogRecord.h:323
virtual void lsst::pex::logging::LogRecord::setDate ( )
virtual

set the DATE property to the current value of the TIMESTAMP property. The value is a string representation of the TIMESTAMP property, formatted for read-able display.

Unlike setTimestamp(), this function is not called automatically within the LogRecord constructor; thus, a user of this class must call it explicitly to have this property.

This function is intended for use by a Log class that sets the value just before sending this record to the LogDestinations.

void lsst::pex::logging::LogRecord::setShowAll ( bool  yesno)
inline

set whether all of the properties attached to this record should be displayed when the record is rendered. A LogFormatter may or may not choose to honor the preference, according to the purposes of its implmentation.

Parameters
yesnothe preference for showing all. willShowAll() will return this value.

Definition at line 275 of file LogRecord.h.

275 { _showAll = yesno; }
void lsst::pex::logging::LogRecord::setTimestamp ( )

set the TIMESTAMP property to the current time. The value is stored as a lsst::daf::base::DateTime instance.

This is called automatically in the constructor, but it can be reset at any time. If there is also a DATE property, it will be updated as well (see setDate()).

static long long lsst::pex::logging::LogRecord::utcnow ( )
static

return the current UTC time in nanosecs since Jan 1, 1970. This value is suitable for passing to a DateTime constructor.

bool lsst::pex::logging::LogRecord::willRecord ( ) const
inline

return true if the importance level is set loud enough to cause this record to be actually recorded. This value is set at construction time only.

Definition at line 257 of file LogRecord.h.

257 { return _send; }
bool lsst::pex::logging::LogRecord::willShowAll ( ) const
inline

return true if there is a preference by the creator of this record to show all the properties associated with this record. A LogFormatter may or may not choose to honor this preference when this LogRecord is rendered.

Definition at line 265 of file LogRecord.h.

265 { return _showAll; }

Member Data Documentation

lsst::daf::base::PropertySet::Ptr lsst::pex::logging::LogRecord::_data
protected

Definition at line 323 of file LogRecord.h.

bool lsst::pex::logging::LogRecord::_send
protected

Definition at line 320 of file LogRecord.h.

bool lsst::pex::logging::LogRecord::_showAll
protected

Definition at line 321 of file LogRecord.h.

int lsst::pex::logging::LogRecord::_vol
protected

Definition at line 322 of file LogRecord.h.


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