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

Last change on this file since 8339 was 8243, checked in by tbretz, 18 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#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 dbg = { 4 }; // use this for debug messages (blue)
33
34inline _Debug debug(int level)
35{
36 _Debug d;
37 d.level = level;
38 return d;
39}
40
41inline std::ostream &operator<<(std::ostream &lout, _Debug d)
42{
43 MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
44 if (log)
45 log->SetOutputLevel(d.level);
46 return lout;
47}
48
49// ------------------------------- edev ----------------------------
50
51struct _EnableDev { MLog::_flags dev; };
52
53inline _EnableDev edev(MLog::_flags i)
54{
55 _EnableDev e;
56 e.dev = i;
57 return e;
58}
59
60inline std::ostream &operator<<(std::ostream &lout, _EnableDev e)
61{
62 MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
63 if (log)
64 log->EnableOutputDevice(e.dev);
65 return lout;
66}
67
68// ------------------------------- sdev ----------------------------
69
70struct _DisableDev { MLog::_flags dev; };
71
72inline _DisableDev ddev(MLog::_flags i)
73{
74 _DisableDev d;
75 d.dev = i;
76 return d;
77}
78
79inline std::ostream &operator<<(std::ostream &lout, _DisableDev d)
80{
81 MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
82 if (log)
83 log->EnableOutputDevice(d.dev);
84 return lout;
85}
86
87// ------------------------------ Macros ---------------------------
88
89#ifndef __CINT__
90#define dbginf __FILE__ << " l." << dec << __LINE__ << ": "
91#endif
92
93#endif
Note: See TracBrowser for help on using the repository browser.