source: trunk/Mars/mbase/MLogManip.h@ 10305

Last change on this file since 10305 was 8744, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 2.1 KB
Line 
1#ifndef MARS_MLogManip
2#define MARS_MLogManip
3
4#include <iomanip>
5
6#ifndef MARS_MLog
7#include "MLog.h"
8#endif
9
10// --------------------- simple manipulators -----------------------
11
12enum MLogManip {
13 underline
14};
15
16inline std::ostream &operator<<(std::ostream &lout, MLogManip)
17{
18 MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
19 if (log)
20 log->Underline();
21 return lout;
22}
23
24// ----------------------------- debug -----------------------------
25
26struct _Debug { int level; };
27
28const _Debug all = { 0 }; // use this for output in any case
29const _Debug err = { 1 }; // use this for fatal errors (red)
30const _Debug warn = { 2 }; // use this for wrnings (yellow)
31const _Debug inf = { 3 }; // use this for informations (green)
32const _Debug inf2 = { 4 }; // use this for informations (green)
33const _Debug inf3 = { 5 }; // use this for informations (green)
34const _Debug dbg = { 6 }; // use this for debug messages (blue)
35
36inline _Debug debug(int level)
37{
38 _Debug d;
39 d.level = level;
40 return d;
41}
42
43inline std::ostream &operator<<(std::ostream &lout, _Debug d)
44{
45 MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
46 if (log)
47 log->SetOutputLevel(d.level);
48 return lout;
49}
50
51// ------------------------------- edev ----------------------------
52
53struct _EnableDev { MLog::_flags dev; };
54
55inline _EnableDev edev(MLog::_flags i)
56{
57 _EnableDev e;
58 e.dev = i;
59 return e;
60}
61
62inline std::ostream &operator<<(std::ostream &lout, _EnableDev e)
63{
64 MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
65 if (log)
66 log->EnableOutputDevice(e.dev);
67 return lout;
68}
69
70// ------------------------------- sdev ----------------------------
71
72struct _DisableDev { MLog::_flags dev; };
73
74inline _DisableDev ddev(MLog::_flags i)
75{
76 _DisableDev d;
77 d.dev = i;
78 return d;
79}
80
81inline std::ostream &operator<<(std::ostream &lout, _DisableDev d)
82{
83 MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
84 if (log)
85 log->EnableOutputDevice(d.dev);
86 return lout;
87}
88
89// ------------------------------ Macros ---------------------------
90
91#ifndef __CINT__
92#define dbginf __FILE__ << " l." << dec << __LINE__ << ": "
93#endif
94
95#endif
Note: See TracBrowser for help on using the repository browser.