| 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 dbg  = { 4 }; // use this for debug messages (blue) | 
|---|
| 33 |  | 
|---|
| 34 | inline _Debug debug(int level) | 
|---|
| 35 | { | 
|---|
| 36 | _Debug d; | 
|---|
| 37 | d.level = level; | 
|---|
| 38 | return d; | 
|---|
| 39 | } | 
|---|
| 40 |  | 
|---|
| 41 | inline 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 |  | 
|---|
| 51 | struct _EnableDev { MLog::_flags dev; }; | 
|---|
| 52 |  | 
|---|
| 53 | inline _EnableDev edev(MLog::_flags i) | 
|---|
| 54 | { | 
|---|
| 55 | _EnableDev e; | 
|---|
| 56 | e.dev = i; | 
|---|
| 57 | return e; | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | inline 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 |  | 
|---|
| 70 | struct _DisableDev { MLog::_flags dev; }; | 
|---|
| 71 |  | 
|---|
| 72 | inline _DisableDev ddev(MLog::_flags i) | 
|---|
| 73 | { | 
|---|
| 74 | _DisableDev d; | 
|---|
| 75 | d.dev = i; | 
|---|
| 76 | return d; | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | inline 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 | 
|---|