1 | #ifndef MARS_MLogManip
|
---|
2 | #define MARS_MLogManip
|
---|
3 |
|
---|
4 | #include <iomanip>
|
---|
5 |
|
---|
6 | #include "MLog.h"
|
---|
7 |
|
---|
8 | // --------------------- simple manipulators -----------------------
|
---|
9 |
|
---|
10 | enum MLogManip {
|
---|
11 | underline
|
---|
12 | };
|
---|
13 |
|
---|
14 | inline std::ostream &operator<<(std::ostream &lout, MLogManip)
|
---|
15 | {
|
---|
16 | MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
|
---|
17 | if (log)
|
---|
18 | log->Underline();
|
---|
19 | return lout;
|
---|
20 | }
|
---|
21 |
|
---|
22 |
|
---|
23 | // ----------------------------- debug -----------------------------
|
---|
24 |
|
---|
25 | struct _Debug { int level; };
|
---|
26 |
|
---|
27 | const _Debug all = { 0 }; // use this for output in any case
|
---|
28 | const _Debug err = { 1 }; // use this for fatal errors (red)
|
---|
29 | const _Debug warn = { 2 }; // use this for wrnings (yellow)
|
---|
30 | const _Debug inf = { 3 }; // use this for informations (green)
|
---|
31 | const _Debug dbg = { 4 }; // use this for debug messages (blue)
|
---|
32 |
|
---|
33 | inline _Debug debug(int level)
|
---|
34 | {
|
---|
35 | _Debug d;
|
---|
36 | d.level = level;
|
---|
37 | return d;
|
---|
38 | }
|
---|
39 |
|
---|
40 | inline 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 |
|
---|
50 | struct _EnableDev { MLog::_flags dev; };
|
---|
51 |
|
---|
52 | inline _EnableDev edev(MLog::_flags i)
|
---|
53 | {
|
---|
54 | _EnableDev e;
|
---|
55 | e.dev = i;
|
---|
56 | return e;
|
---|
57 | }
|
---|
58 |
|
---|
59 | inline 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 |
|
---|
69 | struct _DisableDev { MLog::_flags dev; };
|
---|
70 |
|
---|
71 | inline _DisableDev ddev(MLog::_flags i)
|
---|
72 | {
|
---|
73 | _DisableDev d;
|
---|
74 | d.dev = i;
|
---|
75 | return d;
|
---|
76 | }
|
---|
77 |
|
---|
78 | inline 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
|
---|