| 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 |  | 
|---|
| 12 | enum MLogManip { | 
|---|
| 13 | underline | 
|---|
| 14 | }; | 
|---|
| 15 |  | 
|---|
| 16 | inline 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 |  | 
|---|
| 26 | struct _Debug { int level; }; | 
|---|
| 27 |  | 
|---|
| 28 | const _Debug all  = { 0 }; // use this for output in any case | 
|---|
| 29 | const _Debug err  = { 1 }; // use this for fatal errors (red) | 
|---|
| 30 | const _Debug warn = { 2 }; // use this for wrnings (yellow) | 
|---|
| 31 | const _Debug inf  = { 3 }; // use this for informations (green) | 
|---|
| 32 | const _Debug inf2 = { 4 }; // use this for informations (green) | 
|---|
| 33 | const _Debug inf3 = { 5 }; // use this for informations (green) | 
|---|
| 34 | const _Debug dbg  = { 6 }; // use this for debug messages (blue) | 
|---|
| 35 |  | 
|---|
| 36 | inline _Debug debug(int level) | 
|---|
| 37 | { | 
|---|
| 38 | _Debug d; | 
|---|
| 39 | d.level = level; | 
|---|
| 40 | return d; | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | inline 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 |  | 
|---|
| 53 | struct _EnableDev { MLog::_flags dev; }; | 
|---|
| 54 |  | 
|---|
| 55 | inline _EnableDev edev(MLog::_flags i) | 
|---|
| 56 | { | 
|---|
| 57 | _EnableDev e; | 
|---|
| 58 | e.dev = i; | 
|---|
| 59 | return e; | 
|---|
| 60 | } | 
|---|
| 61 |  | 
|---|
| 62 | inline 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 |  | 
|---|
| 72 | struct _DisableDev { MLog::_flags dev; }; | 
|---|
| 73 |  | 
|---|
| 74 | inline _DisableDev ddev(MLog::_flags i) | 
|---|
| 75 | { | 
|---|
| 76 | _DisableDev d; | 
|---|
| 77 | d.dev = i; | 
|---|
| 78 | return d; | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 | inline 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 | 
|---|