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
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
pex_logging
11.0+1
include
lsst
pex
logging
LogRecord.h
Go to the documentation of this file.
1
// -*- lsst-c++ -*-
2
3
/*
4
* LSST Data Management System
5
* Copyright 2008, 2009, 2010 LSST Corporation.
6
*
7
* This product includes software developed by the
8
* LSST Project (http://www.lsst.org/).
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
*
20
* You should have received a copy of the LSST License Statement and
21
* the GNU General Public License along with this program. If not,
22
* see <http://www.lsstcorp.org/LegalNotices/>.
23
*/
24
30
#ifndef LSST_PEX_LOGRECORD_H
31
#define LSST_PEX_LOGRECORD_H
32
33
#include "
lsst/daf/base/PropertySet.h
"
34
35
#include <boost/shared_ptr.hpp>
36
#include <boost/format.hpp>
37
#include <string>
38
#include <sys/time.h>
39
40
#define LSST_LP_COMMENT "COMMENT"
41
#define LSST_LP_TIMESTAMP "TIMESTAMP"
42
#define LSST_LP_DATE "DATE"
43
#define LSST_LP_LOG "LOG"
44
#define LSST_LP_LEVEL "LEVEL"
45
46
namespace
lsst {
47
namespace
pex {
48
namespace
logging {
49
61
template
<
class
T>
62
class
RecordProperty
{
63
public
:
64
typedef
T
ValueType
;
65
71
RecordProperty
(
const
std::string& pname,
const
T& pvalue)
72
:
name
(pname),
value
(pvalue) { }
73
77
void
addTo
(
lsst::daf::base::PropertySet
& set) { set.
add
(this->
name
, this->
value
); }
78
79
const
std::string
name
;
80
const
T&
value
;
81
};
82
83
/*
84
* a shorthand version of the RecordProperty class
85
*/
86
template
<
class
T>
87
class
Prop
:
public
RecordProperty
<T> {
88
public
:
89
Prop
(
const
std::string& pname,
const
T&
value
)
90
:
RecordProperty
<T>(pname, value) { }
91
};
92
99
class
LogRecord
{
100
public
:
101
114
LogRecord
(
int
threshold,
int
importance,
bool
showAll=
false
);
115
131
LogRecord
(
int
threshold,
int
importance,
132
const
lsst::daf::base::PropertySet
& preamble,
bool
showAll=
false
);
133
137
LogRecord
(
const
LogRecord
& that)
138
:
_send
(that.
_send
),
_showAll
(that.
_showAll
),
_vol
(that.
_vol
),
_data
()
139
{
140
_data
= that.
_data
->deepCopy();
141
}
142
146
virtual
~LogRecord
();
147
151
LogRecord
&
operator=
(
const
LogRecord
& that) {
152
_send
= that.
_send
;
153
_showAll
= that.
_showAll
;
154
_vol
= that.
_vol
;
155
_data
= that.
_data
;
156
return
*
this
;
157
}
158
165
void
addComment
(
const
std::string& comment) {
166
if
(
_send
)
_data
->add(
LSST_LP_COMMENT
, comment);
167
}
168
173
void
addComment
(
const
boost::format
& comment) {
174
if
(
_send
)
addComment
(comment.str());
175
}
176
180
template
<
class
T>
181
void
addProperty
(
const
RecordProperty<T>
& property);
182
186
template
<
class
T>
187
void
addProperty
(
const
std::string&
name
,
const
T&
val
);
188
194
void
addProperties
(
const
lsst::daf::base::PropertySet
& props);
195
201
void
addProperties
(
const
lsst::daf::base::PropertySet::Ptr
& props) {
202
addProperties
(*props);
203
}
204
209
const
lsst::daf::base::PropertySet
&
getProperties
()
const
{
return
data
(); }
210
215
lsst::daf::base::PropertySet
&
getProperties
() {
return
data
(); }
216
221
const
lsst::daf::base::PropertySet
&
data
()
const
{
return
*
_data
; }
222
227
lsst::daf::base::PropertySet
&
data
() {
return
*
_data
; }
228
233
size_t
countParamNames
() {
234
std::vector<std::string> names =
data
().
paramNames
(
false
);
235
return
names.size();
236
}
237
244
size_t
countParamValues
()
const
;
245
250
int
getImportance
()
const
{
return
_vol
; }
251
257
bool
willRecord
()
const
{
return
_send
; }
258
265
bool
willShowAll
()
const
{
return
_showAll
; }
266
275
void
setShowAll
(
bool
yesno) {
_showAll
= yesno; }
276
285
void
setTimestamp
();
286
299
virtual
void
setDate
();
300
305
static
long
long
utcnow
();
306
307
protected
:
308
LogRecord
() :
_send
(false),
_vol
(10),
_data
(new lsst::daf::base::
PropertySet
()) { }
309
313
void
_init
() {
314
if
(
_send
) {
315
_data
->set(
"LEVEL"
,
_vol
);
316
setDate
();
317
}
318
}
319
320
bool
_send
;
// true if this record should be sent to the log
321
bool
_showAll
;
// true if there is preference to have all data displayed
322
int
_vol
;
// the importance volume of this message
323
lsst::daf::base::PropertySet::Ptr
_data
;
324
};
325
326
template
<
class
T>
327
void
LogRecord::addProperty
(
const
RecordProperty<T>
& property) {
328
if
(
_send
)
property
.addTo(
_data
);
329
}
330
331
template
<
class
T>
332
void
LogRecord::addProperty
(
const
std::string&
name
,
const
T&
val
) {
333
if
(
_send
)
data
().
add
(name, val);
334
}
335
336
337
338
}}}
// end lsst::pex::logging
339
340
#endif // end LSST_PEX_LOGRECORD_H
lsst::pex::logging::LogRecord::getProperties
lsst::daf::base::PropertySet & getProperties()
Definition:
LogRecord.h:215
lsst::pex.config.history.format
def format
Definition:
history.py:127
lsst::daf::base::PropertySet::paramNames
std::vector< std::string > paramNames(bool topLevelOnly=true) const
Definition:
PropertySet.cc:142
name
table::Key< std::string > name
Definition:
ApCorrMap.cc:71
lsst::pex::logging::LogRecord::addComment
void addComment(const std::string &comment)
Definition:
LogRecord.h:165
lsst::pex::logging::LogRecord::addProperties
void addProperties(const lsst::daf::base::PropertySet::Ptr &props)
Definition:
LogRecord.h:201
lsst::pex::logging::RecordProperty::ValueType
T ValueType
Definition:
LogRecord.h:64
lsst::pex::logging::LogRecord::willShowAll
bool willShowAll() const
Definition:
LogRecord.h:265
lsst::pex::logging::LogRecord::willRecord
bool willRecord() const
Definition:
LogRecord.h:257
lsst::pex::logging::Prop
Definition:
LogRecord.h:87
lsst::daf::base::PropertySet::Ptr
boost::shared_ptr< PropertySet > Ptr
Definition:
PropertySet.h:90
lsst::pex::logging::LogRecord::utcnow
static long long utcnow()
lsst::pex::logging::LogRecord::data
lsst::daf::base::PropertySet & data()
Definition:
LogRecord.h:227
lsst::pex::logging::LogRecord::data
const lsst::daf::base::PropertySet & data() const
Definition:
LogRecord.h:221
lsst::pex::logging::LogRecord::_vol
int _vol
Definition:
LogRecord.h:322
lsst::pex::logging::LogRecord::_init
void _init()
Definition:
LogRecord.h:313
lsst::pex::logging::LogRecord::setDate
virtual void setDate()
val
bool val
Definition:
DevicePreference.cc:55
lsst::pex::logging::LogRecord
a container for constructing a single Log record
Definition:
LogRecord.h:99
lsst::pex::logging::RecordProperty::RecordProperty
RecordProperty(const std::string &pname, const T &pvalue)
Definition:
LogRecord.h:71
lsst::pex::logging::LogRecord::LogRecord
LogRecord(const LogRecord &that)
Definition:
LogRecord.h:137
lsst::pex::logging::LogRecord::~LogRecord
virtual ~LogRecord()
lsst::pex::logging::LogRecord::addProperty
void addProperty(const RecordProperty< T > &property)
Definition:
LogRecord.h:327
lsst::pex::logging::LogRecord::_data
lsst::daf::base::PropertySet::Ptr _data
Definition:
LogRecord.h:323
lsst::pex::logging::LogRecord::_send
bool _send
Definition:
LogRecord.h:320
lsst::pex::logging::LogRecord::LogRecord
LogRecord()
Definition:
LogRecord.h:308
LSST_LP_COMMENT
#define LSST_LP_COMMENT
Definition:
LogRecord.h:40
lsst::pex::logging::LogRecord::countParamNames
size_t countParamNames()
Definition:
LogRecord.h:233
lsst::pex::logging::LogRecord::getImportance
int getImportance() const
Definition:
LogRecord.h:250
lsst::pex::logging::RecordProperty::name
const std::string name
Definition:
LogRecord.h:79
lsst::pex::logging::LogRecord::_showAll
bool _showAll
Definition:
LogRecord.h:321
lsst::pex::logging::LogRecord::addComment
void addComment(const boost::format &comment)
Definition:
LogRecord.h:173
lsst::daf::base::PropertySet
Class for storing generic metadata.
Definition:
PropertySet.h:82
lsst::pex::logging::RecordProperty::addTo
void addTo(lsst::daf::base::PropertySet &set)
Definition:
LogRecord.h:77
lsst::pex::logging::Prop::Prop
Prop(const std::string &pname, const T &value)
Definition:
LogRecord.h:89
lsst::pex::logging::LogRecord::countParamValues
size_t countParamValues() const
PropertySet.h
Interface for PropertySet class.
lsst::pex::logging::LogRecord::setShowAll
void setShowAll(bool yesno)
Definition:
LogRecord.h:275
lsst::daf::base::PropertySet::add
void add(std::string const &name, T const &value)
Definition:
PropertySet.cc:619
lsst::pex::logging::RecordProperty
a container for a named data property for a LogRecord
Definition:
LogRecord.h:62
lsst::pex::logging::LogRecord::addProperties
void addProperties(const lsst::daf::base::PropertySet &props)
lsst::pex::logging::LogRecord::getProperties
const lsst::daf::base::PropertySet & getProperties() const
Definition:
LogRecord.h:209
lsst::pex::logging::RecordProperty::value
const T & value
Definition:
LogRecord.h:80
lsst::pex::logging::LogRecord::operator=
LogRecord & operator=(const LogRecord &that)
Definition:
LogRecord.h:151
lsst::pex::logging::LogRecord::setTimestamp
void setTimestamp()
Generated on Thu Sep 24 2015 02:29:23 for LSSTApplications by
1.8.5