source: trunk/MagicSoft/Mars/mbase/MLogManip.h@ 4655

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