root/lang/objective-cplusplus/i3/trunk/src/mil/include/mil/os-unix/Debug.h @ 34447

Revision 34447, 0.8 kB (checked in by saturday06, 4 years ago)

iojasdfaodfd

Line 
1#pragma once
2
3#ifndef NDEBUG
4
5namespace mil {
6namespace log {
7
8using namespace std;
9using namespace boost;
10
11class Logger {
12    stringstream data;
13    string file;
14    int line;
15    bool will_abort;
16public:
17    void operator()() const {}
18    template <typename T>
19    Logger& operator<<(const T& op) {
20        data << op;
21        return *this;
22    }
23    Logger(const char* file, int line, bool will_abort = false)
24            : file(file), line(line), will_abort(will_abort) {
25    }
26    ~Logger() {
27        cout << data.str() << "," << file << ":" << line << endl;
28        //cout << data.str() << flush;
29        if (will_abort) {
30            cerr << "mil_abort() !" << endl;
31            *((volatile int*)0) = -1;
32            cerr << "SEGV suppressed !" << endl;
33            //abort();
34        }
35    }
36};
37}
38}
39#endif
40
Note: See TracBrowser for help on using the browser.