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
BlockTimingLog.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_LOGGING_BLOCKTIMINGLOG_H
31
#define LSST_PEX_LOGGING_BLOCKTIMINGLOG_H
32
33
#include "
lsst/pex/logging/LogRecord.h
"
34
#include "
lsst/pex/logging/Log.h
"
35
36
#include <sys/time.h>
37
#include <sys/resource.h>
38
#include <boost/scoped_ptr.hpp>
39
40
namespace
lsst {
41
namespace
pex {
42
namespace
logging {
43
59
class
BlockTimingLog
:
public
Log
{
60
public
:
61
65
enum
usageData
{
69
NOUDATA
= 0,
70
74
UTIME
= 1,
75
79
STIME
= 2,
80
85
SUTIME
= 3,
86
91
MEMSZ
= 4,
92
96
NSWAP
= 16,
97
101
BLKIN
= 32,
102
106
BLKOUT
= 64,
107
112
BLKIO
= 96,
113
118
MINFLT
= 128,
119
124
MAJFLT
= 256,
125
130
LINUXUDATA
= 387,
131
135
ALLUDATA
= 511,
136
141
PARENTUDATA
= 8192
142
};
143
147
static
const
int
INSTRUM
;
// = Log::INFO - 3
148
153
static
const
std::string
STATUS
;
154
159
static
const
std::string
START
;
160
165
static
const
std::string
END
;
166
180
BlockTimingLog
(
const
Log
& parent,
const
std::string&
name
,
181
int
tracelev=
BlockTimingLog::INSTRUM
,
182
int
usageFlags=
PARENTUDATA
,
const
std::string& funcName=
""
);
183
187
BlockTimingLog
(
const
BlockTimingLog
& that)
188
:
Log
(*this),
_tracelev
(that.
_tracelev
),
_funcName
(that.
_funcName
)
189
{ }
190
194
BlockTimingLog
&
operator=
(
const
BlockTimingLog
& that) {
195
Log::operator=
(that);
196
_tracelev
= that.
_tracelev
;
197
_funcName
= that.
_funcName
;
198
return
*
this
;
199
}
200
205
int
getUsageFlags
()
const
{
return
_usageFlags
; }
206
214
void
setUsageFlags
(
int
flags) {
215
_usageFlags
= flags;
216
if
((flags &
PARENTUDATA
) > 0)
_usageFlags
|=
_pusageFlags
;
217
}
218
227
void
addUsageFlags
(
int
flags) {
228
_usageFlags
|= flags;
229
if
((flags &
PARENTUDATA
) > 0)
_usageFlags
|=
_pusageFlags
;
230
}
231
246
BlockTimingLog
*
createForBlock
(
const
std::string&
name
,
247
int
tracelev=
Log::INHERIT_THRESHOLD
,
248
const
std::string& funcName=
""
)
249
{
250
BlockTimingLog
*out =
new
BlockTimingLog
(*
this
, name, tracelev,
251
PARENTUDATA
, funcName);
252
// out->setShowAll(true);
253
out->
start
();
254
return
out;
255
}
256
260
BlockTimingLog
*
timeBlock
(
const
std::string&
name
,
261
int
tracelev=
Log::INHERIT_THRESHOLD
,
262
const
std::string& funcName=
""
)
263
{
264
return
createForBlock
(name, tracelev, funcName);
265
}
266
270
virtual
~BlockTimingLog
();
271
276
void
start
() {
277
if
(
sends
(
_tracelev
)) {
278
std::string msg(
"Starting "
);
279
msg +=
_funcName
;
280
281
LogRecord
rec(
getThreshold
(),
_tracelev
,
getPreamble
(),
282
willShowAll
());
283
rec.
addComment
(msg);
284
rec.
addProperty
(
STATUS
,
START
);
285
if
(
_usageFlags
)
addUsageProps
(rec);
286
send
(rec);
287
}
288
}
289
294
void
start
(
const
std::string& funcName) {
295
if
(funcName.length() > 0)
_funcName
= funcName;
296
start
();
297
}
298
303
void
done
() {
304
if
(
sends
(
_tracelev
)) {
305
std::string msg(
"Ending "
);
306
msg +=
_funcName
;
307
308
LogRecord
rec(
getThreshold
(),
_tracelev
,
getPreamble
(),
309
willShowAll
());
310
rec.
addComment
(msg);
311
rec.
addProperty
(
STATUS
,
END
);
312
if
(
_usageFlags
)
addUsageProps
(rec);
313
send
(rec);
314
}
315
}
316
321
int
getInstrumentationLevel
()
const
{
return
_tracelev
; }
322
327
const
std::string&
getFunctionName
()
const
{
return
_funcName
; }
328
333
void
addUsageProps
(
LogRecord
& rec);
334
335
private
:
336
int
_tracelev
;
337
int
_pusageFlags
,
_usageFlags
;
338
std::string
_funcName
;
339
boost::scoped_ptr<struct rusage>
_usage
;
340
};
341
342
}}}
// end lsst::pex::logging
343
#endif // end LSST_PEX_BLOCKTIMINGLOG_H
lsst::pex::logging::BlockTimingLog::_funcName
std::string _funcName
Definition:
BlockTimingLog.h:338
lsst::pex::logging::BlockTimingLog::start
void start()
Definition:
BlockTimingLog.h:276
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::Log::getThreshold
int getThreshold() const
Definition:
Log.h:281
lsst::pex::logging::BlockTimingLog::PARENTUDATA
Definition:
BlockTimingLog.h:141
lsst::pex::logging::BlockTimingLog::START
static const std::string START
Definition:
BlockTimingLog.h:159
lsst::pex::logging::BlockTimingLog::BlockTimingLog
BlockTimingLog(const Log &parent, const std::string &name, int tracelev=BlockTimingLog::INSTRUM, int usageFlags=PARENTUDATA, const std::string &funcName="")
Definition:
BlockTimingLog.cc:41
lsst::pex::logging::BlockTimingLog::SUTIME
Definition:
BlockTimingLog.h:85
lsst::pex::logging::Log::operator=
Log & operator=(const Log &that)
lsst::pex::logging::Log::send
void send(const LogRecord &record)
lsst::pex::logging::BlockTimingLog::getFunctionName
const std::string & getFunctionName() const
Definition:
BlockTimingLog.h:327
lsst::pex::logging::BlockTimingLog::_tracelev
int _tracelev
Definition:
BlockTimingLog.h:336
lsst::pex::logging::Log
a place to record messages and descriptions of the state of processing.
Definition:
Log.h:154
lsst::pex::logging::BlockTimingLog::start
void start(const std::string &funcName)
Definition:
BlockTimingLog.h:294
lsst::pex::logging::BlockTimingLog::LINUXUDATA
Definition:
BlockTimingLog.h:130
lsst::pex::logging::BlockTimingLog::createForBlock
BlockTimingLog * createForBlock(const std::string &name, int tracelev=Log::INHERIT_THRESHOLD, const std::string &funcName="")
Definition:
BlockTimingLog.h:246
lsst::pex::logging::BlockTimingLog::getUsageFlags
int getUsageFlags() const
Definition:
BlockTimingLog.h:205
lsst::pex::logging::BlockTimingLog::BLKOUT
Definition:
BlockTimingLog.h:106
lsst::pex::logging::LogRecord
a container for constructing a single Log record
Definition:
LogRecord.h:99
LogRecord.h
definition of the LogRecord, RecordProperty and Prop classes
lsst::pex::logging::BlockTimingLog::setUsageFlags
void setUsageFlags(int flags)
Definition:
BlockTimingLog.h:214
lsst::pex::logging::Log::INHERIT_THRESHOLD
static const int INHERIT_THRESHOLD
Definition:
Log.h:183
lsst::pex::logging::BlockTimingLog::operator=
BlockTimingLog & operator=(const BlockTimingLog &that)
Definition:
BlockTimingLog.h:194
lsst::pex::logging::BlockTimingLog::STATUS
static const std::string STATUS
Definition:
BlockTimingLog.h:153
lsst::pex::logging::BlockTimingLog::BLKIO
Definition:
BlockTimingLog.h:112
lsst::pex::logging::Log::willShowAll
bool willShowAll() const
Definition:
Log.h:335
lsst::pex::logging::BlockTimingLog::MEMSZ
Definition:
BlockTimingLog.h:91
lsst::pex::logging::BlockTimingLog::timeBlock
BlockTimingLog * timeBlock(const std::string &name, int tracelev=Log::INHERIT_THRESHOLD, const std::string &funcName="")
Definition:
BlockTimingLog.h:260
lsst::pex::logging::LogRecord::addProperty
void addProperty(const RecordProperty< T > &property)
Definition:
LogRecord.h:327
lsst::pex::logging::BlockTimingLog::BLKIN
Definition:
BlockTimingLog.h:101
lsst::pex::logging::BlockTimingLog::done
void done()
Definition:
BlockTimingLog.h:303
lsst::pex::logging::BlockTimingLog::NOUDATA
Definition:
BlockTimingLog.h:69
lsst::pex::logging::BlockTimingLog::_usageFlags
int _usageFlags
Definition:
BlockTimingLog.h:337
lsst::pex::logging::BlockTimingLog::getInstrumentationLevel
int getInstrumentationLevel() const
Definition:
BlockTimingLog.h:321
lsst::pex::logging::Log::sends
bool sends(int importance) const
Definition:
Log.h:302
lsst::pex::logging::BlockTimingLog::ALLUDATA
Definition:
BlockTimingLog.h:135
lsst::pex::logging::BlockTimingLog::_usage
boost::scoped_ptr< struct rusage > _usage
Definition:
BlockTimingLog.h:339
lsst::pex::logging::BlockTimingLog::~BlockTimingLog
virtual ~BlockTimingLog()
Definition:
BlockTimingLog.cc:63
lsst::pex::logging::BlockTimingLog::MINFLT
Definition:
BlockTimingLog.h:118
lsst::pex::logging::BlockTimingLog::addUsageFlags
void addUsageFlags(int flags)
Definition:
BlockTimingLog.h:227
lsst::pex::logging::BlockTimingLog::addUsageProps
void addUsageProps(LogRecord &rec)
Definition:
BlockTimingLog.cc:65
lsst::pex::logging::BlockTimingLog::BlockTimingLog
BlockTimingLog(const BlockTimingLog &that)
Definition:
BlockTimingLog.h:187
lsst::pex::logging::Log::getPreamble
const lsst::daf::base::PropertySet & getPreamble()
Definition:
Log.h:580
Log.h
lsst::pex::logging::BlockTimingLog::MAJFLT
Definition:
BlockTimingLog.h:124
lsst::pex::logging::BlockTimingLog::usageData
usageData
Definition:
BlockTimingLog.h:65
lsst::pex::logging::BlockTimingLog::END
static const std::string END
Definition:
BlockTimingLog.h:165
lsst::pex::logging::BlockTimingLog::UTIME
Definition:
BlockTimingLog.h:74
lsst::pex::logging::BlockTimingLog::STIME
Definition:
BlockTimingLog.h:79
lsst::pex::logging::BlockTimingLog
Definition:
BlockTimingLog.h:59
lsst::pex::logging::BlockTimingLog::_pusageFlags
int _pusageFlags
Definition:
BlockTimingLog.h:337
lsst::pex::logging::BlockTimingLog::INSTRUM
static const int INSTRUM
Definition:
BlockTimingLog.h:147
lsst::pex::logging::BlockTimingLog::NSWAP
Definition:
BlockTimingLog.h:96
Generated on Thu Sep 24 2015 02:29:23 for LSSTApplications by
1.8.5