Jpp
software
Jeep
JMessage.hh
Go to the documentation of this file.
1
#ifndef __JEEP__JMESSAGE__
2
#define __JEEP__JMESSAGE__
3
4
#include <iostream>
5
6
#include "
JLang/JFileStream.hh
"
7
#include "
Jeep/JColor.hh
"
8
9
10
/**
11
* \file
12
* General purpose messaging.
13
* \author mdejong
14
*/
15
16
extern
int
debug
;
//!< debug level
17
extern
int
qaqc
;
//!< QA/QC file descriptor
18
19
namespace
JEEP
{}
20
namespace
JPP
{
using namespace
JEEP
; }
21
22
namespace
JEEP
{
23
24
/**
25
* Debug level.
26
*/
27
enum
JMessage_t
{
28
29
debug_t
= 3,
//!< debug
30
status_t
= 2,
//!< status
31
warning_t
= 2,
//!< warning
32
notice_t
= 1,
//!< notice
33
error_t
= 0,
//!< error
34
fatal_t
= 0
//!< fatal; exit
35
};
36
37
38
/**
39
* Auxiliary class for handling debug parameter within a class.
40
* Note that the derived class should include the statement <tt>using JMessage<..>::debug;</tt>
41
* otherwise the linker will fail.
42
*/
43
template
<
class
T>
44
struct
JMessage
{
45
static
int
debug
;
// debug level
46
};
47
48
49
/**
50
* debug level (default is off).
51
*/
52
template
<
class
T>
53
int
JMessage<T>::debug
= 0;
54
}
55
56
57
/**
58
* Message macros.
59
*
60
* \param A std::ostream compatible output
61
*/
62
#define DEBUG(A) do { if (debug >= JEEP::debug_t) { std::cout << A << std::flush; } } while (0)
63
#define STATUS(A) do { if (debug >= JEEP::status_t) { std::cout << A << std::flush; } } while (0)
64
#define NOTICE(A) do { if (debug >= JEEP::notice_t) { std::cerr << A << std::flush; } } while (0)
65
#define WARNING(A) do { if (debug >= JEEP::warning_t) { std::cerr << "WARNING: " << A << std::flush; } } while (0)
66
#define ERROR(A) do { { std::cerr << "ERROR: " << A << std::flush; } } while (0)
67
#define FATAL(A) do { { std::cerr << "FATAL: " << A << std::endl; exit(1); } } while (0)
68
69
70
/**
71
* Make std::ostream compatible output for variadic macro.
72
*
73
* When called,
74
* - first argument should correspond to a dummy value;
75
* - second to the ##__VA_ARGS__ macro; and
76
* - third to the fall back value (e.g. "");
77
*
78
* \param A dummy value
79
* \param B ##__VA_ARGS__ macro
80
* \return output
81
*/
82
#define VARGS_STREAM(A, B, ...) B
83
84
85
/**
86
* Assert macro.
87
*
88
* \param A test
89
*/
90
#define ASSERT(A, ...) do { \
91
if (A) { NOTICE(JEEP::GREEN << "Test at " << __FILE__ << ":" << __LINE__ << " (" << #A << ") \"" << VARGS_STRING("", ##__VA_ARGS__, "") << "\" passed." << JEEP::RESET << std::endl); } \
92
else { FATAL (JEEP::RED << "Test at " << __FILE__ << ":" << __LINE__ << " (" << #A << ") \"" << VARGS_STRING("", ##__VA_ARGS__, "") << "\" failed." << JEEP::RESET << std::endl); } } while (0)
93
94
95
/**
96
* QA/QC output macro.
97
*
98
* \param A ostream compatible output
99
*/
100
#define QAQC(A) do { if (qaqc > 0) { JLANG::JFileOutputStream(qaqc) << A; } } while (0)
101
102
#endif
JEEP::fatal_t
fatal; exit
Definition:
JMessage.hh:34
JEEP
General puprpose classes and methods.
Definition:
JArgs.hh:15
JEEP::notice_t
notice
Definition:
JMessage.hh:32
JEEP::JMessage_t
JMessage_t
Debug level.
Definition:
JMessage.hh:27
JFileStream.hh
JEEP::error_t
error
Definition:
JMessage.hh:33
JEEP::warning_t
warning
Definition:
JMessage.hh:31
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition:
JAAnetToolkit.hh:37
debug
int debug
debug level
Definition:
JSirene.cc:59
JEEP::status_t
status
Definition:
JMessage.hh:30
JEEP::JMessage::debug
static int debug
debug level (default is off).
Definition:
JMessage.hh:45
qaqc
int qaqc
QA/QC file descriptor.
JEEP::debug_t
debug
Definition:
JMessage.hh:29
JEEP::JMessage
Auxiliary class for handling debug parameter within a class.
Definition:
JMessage.hh:44
JColor.hh
Generated by
1.8.16