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
Debug.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_DEBUG_H
31 #define LSST_PEX_LOGGING_DEBUG_H
32 
33 #include "lsst/pex/logging/Log.h"
34 #include <cstdarg>
35 
36 namespace lsst {
37 namespace pex {
38 namespace logging {
39 
40 #ifndef LSST_DEBUGGING_ON
41 #define LSST_DEBUGGING_ON
42 #endif
43 
44 #ifdef LSST_NO_DEBUG
45 #undef LSST_DEBUGGING_ON
46 #undef LSST_MAX_DEBUG
47 #endif
48 
49 #ifndef LSST_DEBUGGING_ON
50 #ifndef LSST_MAX_DEBUG
51 #define LSST_MAX_DEBUG 0
52 #endif
53 #endif
54 
55 #ifndef LSST_MAX_DEBUG
56 #define LSST_MAX_DEBUG 0
57 #endif
58 
75 class Debug : public Log {
76 public:
77 
78  Debug(const std::string& name, int verbosity=-1*Log::INHERIT_THRESHOLD)
79  : Log(Log::getDefaultLog(), name, -1*verbosity) { }
80 
81  Debug(const Log& parent, const std::string& name,
82  int verbosity=-1*Log::INHERIT_THRESHOLD)
83  : Log(parent, name , -1*verbosity) { }
84  Debug(const Debug& that) : Log(that) { }
85 
86  Debug& operator=(const Debug& that) {
87  if (this != &that) dynamic_cast<Log*>(this)->operator=(that);
88  return *this;
89  }
90 
104  void debug(int verbosity, const std::string& message) {
105  log(-1*verbosity, message);
106  }
107 
118  void debug(int verbosity, const boost::format& message) {
119  log(-1*verbosity, message);
120  }
121 
128  void debug(int verbosity, const char *fmt, ...) {
129  va_list ap;
130  va_start(ap, fmt);
131  debug(verbosity, fmt, ap);
132  va_end(ap);
133  }
134 
142  void debug(int verbosity, const char *fmt, va_list ap) {
143  if (-1 * verbosity < getThreshold()) return;
144  _format(-1*verbosity, fmt, ap);
145  }
146 
152  template<int VERBOSITY>
153  void debug(const std::string& message) {
154  if (LSST_MAX_DEBUG <= 0 || VERBOSITY <= LSST_MAX_DEBUG) {
155  log(-1*VERBOSITY, message);
156  }
157  }
158 
167  template<int VERBOSITY>
168  void debug(const char *fmt, ...) {
169  if (LSST_MAX_DEBUG <= 0 || VERBOSITY <= LSST_MAX_DEBUG) {
170  va_list ap;
171  va_start(ap, fmt);
172  debug(VERBOSITY, fmt, ap);
173  va_end(ap);
174  }
175  }
176 
177 };
178 
185 template <int VERBOSITY>
186 void debug(const std::string& name, const std::string& message) {
187  if (LSST_MAX_DEBUG <= 0 || VERBOSITY <= LSST_MAX_DEBUG) {
188  Debug(name).debug<VERBOSITY>(message);
189  }
190 }
191 
198 template <int VERBOSITY>
199 void debug(const std::string& name, const char *fmt, ...) {
200  if (LSST_MAX_DEBUG <= 0 || VERBOSITY <= LSST_MAX_DEBUG) {
201  va_list ap;
202  va_start(ap, fmt);
203  Debug(name).debug(VERBOSITY, fmt, ap);
204  va_end(ap);
205  }
206 }
207 
208 
209 }}} // end lsst::pex::logging
210 
211 #endif // end LSST_PEX_LOGGING_DEBUG_H
Debug & operator=(const Debug &that)
Definition: Debug.h:86
table::Key< std::string > name
Definition: ApCorrMap.cc:71
int getThreshold() const
Definition: Log.h:281
void _format(int importance, const char *fmt, va_list ap)
void debug(int verbosity, const boost::format &message)
Definition: Debug.h:118
void debug(int verbosity, const char *fmt, va_list ap)
Definition: Debug.h:142
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
static Log & getDefaultLog()
Debug(const std::string &name, int verbosity=-1 *Log::INHERIT_THRESHOLD)
Definition: Debug.h:78
void debug(const char *fmt,...)
Definition: Debug.h:168
static const int INHERIT_THRESHOLD
Definition: Log.h:183
Debug(const Debug &that)
Definition: Debug.h:84
#define LSST_MAX_DEBUG
Definition: Debug.h:56
void debug(int verbosity, const char *fmt,...)
Definition: Debug.h:128
void debug(const std::string &name, const std::string &message)
Definition: Debug.h:186
void debug(int verbosity, const std::string &message)
Definition: Debug.h:104
Debug(const Log &parent, const std::string &name, int verbosity=-1 *Log::INHERIT_THRESHOLD)
Definition: Debug.h:81
void debug(const std::string &message)
Definition: Debug.h:153