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
TracingLog.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_HARNESS_TRACINGLOG_H
31 #define LSST_PEX_HARNESS_TRACINGLOG_H
32 
34 #include "lsst/pex/logging/Log.h"
35 
36 namespace lsst {
37 namespace pex {
38 namespace harness {
39 
40 namespace logging = lsst::pex::logging;
41 
50 class TracingLog : public logging::Log {
51 public:
52 
56  static const int TRACE; // = logging::Log::INFO - 1
57 
61  static const std::string STATUS;
62 
67  static const std::string START;
68 
73  static const std::string END;
74 
86  TracingLog(const logging::Log& parent, const std::string& name,
87  int tracelev=TracingLog::TRACE, const std::string& funcName="");
88 
92  TracingLog(const TracingLog& that)
93  : Log(*this), _tracelev(that._tracelev), _funcName(that._funcName)
94  { }
95 
100  Log::operator=(that);
101  _tracelev = that._tracelev;
102  _funcName = that._funcName;
103  return *this;
104  }
105 
120  TracingLog *createForTraceBlock(const std::string& name,
121  int tracelev=logging::Log::INHERIT_THRESHOLD,
122  const std::string& funcName="")
123  {
124  TracingLog *out = new TracingLog(*this, name, tracelev, funcName);
125  // out->setShowAll(true);
126  out->start();
127  return out;
128  }
129 
133  TracingLog *traceBlock(const std::string& name,
134  int tracelev=logging::Log::INHERIT_THRESHOLD,
135  const std::string& funcName="")
136  {
137  return createForTraceBlock(name, tracelev, funcName);
138  }
139 
143  virtual ~TracingLog();
144 
149  void start() {
150  if (sends(_tracelev)) {
151  std::string msg("Starting ");
152  msg += _funcName;
153  log(_tracelev, msg, STATUS, START);
154  }
155  }
156 
161  void start(const std::string& funcName) {
162  if (funcName.length() > 0) _funcName = funcName;
163  start();
164  }
165 
170  void done() {
171  if (sends(_tracelev)) {
172  std::string msg("Ending ");
173  msg += _funcName;
174  log(_tracelev, msg, STATUS, END);
175  }
176  }
177 
182  int getTraceLevel() const { return _tracelev; }
183 
188  const std::string& getFunctionName() const { return _funcName; }
189 
190 private:
192  std::string _funcName;
193 };
194 
212 TracingLog *setupHarnessLogging(const std::string& runId, int sliceId,
213  const std::string& eventBrokerHost="",
214  const std::string& pipename="unnamed",
215  const std::string& workerid="-1",
216  std::ostream *messageStrm=0,
217  const std::string& logname="harness");
218 
219 }}} // end lsst::pex::harness
220 
221 #endif // end LSST_PEX_LOG_H
const std::string & getFunctionName() const
Definition: TracingLog.h:188
TracingLog * createForTraceBlock(const std::string &name, int tracelev=logging::Log::INHERIT_THRESHOLD, const std::string &funcName="")
Definition: TracingLog.h:120
static const std::string END
Definition: TracingLog.h:73
static const std::string START
Definition: TracingLog.h:67
Log & operator=(const Log &that)
void log(int importance, const std::string &message, const lsst::daf::base::PropertySet &properties)
a place to record messages and descriptions of the state of processing.
Definition: Log.h:154
TracingLog(const logging::Log &parent, const std::string &name, int tracelev=TracingLog::TRACE, const std::string &funcName="")
Definition: TracingLog.cc:45
void start(const std::string &funcName)
Definition: TracingLog.h:161
definition of the DualLog class
TracingLog & operator=(const TracingLog &that)
Definition: TracingLog.h:99
definition of the LogRecord, RecordProperty and Prop classes
static const int INHERIT_THRESHOLD
Definition: Log.h:183
static const std::string STATUS
Definition: TracingLog.h:61
bool sends(int importance) const
Definition: Log.h:302
BlockTimingLog * setupHarnessLogging(const std::string &runId, int sliceId, const std::string &eventBrokerHost, const std::string &pipename, const std::string &workerid, std::ostream *messageStrm, const std::string &logname, int resourceUsageFlags)
create and configure logging for a harness application
Definition: LogUtils.cc:168
TracingLog * traceBlock(const std::string &name, int tracelev=logging::Log::INHERIT_THRESHOLD, const std::string &funcName="")
Definition: TracingLog.h:133
TracingLog(const TracingLog &that)
Definition: TracingLog.h:92