123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #ifndef _LOG_H_
- #define _LOG_H_
- #include <iostream>
- #include <sstream>
- namespace NICE {
- class Log {
- public:
- inline Log(std::ostream& _target = std::cerr)
- : target(&_target), quiet(false) {}
- virtual ~Log();
-
- inline static std::ostream& debug() { return _debugLog(); }
-
- inline static std::ostream& error() { return _errorLog(); }
-
- inline static std::ostream& timing() { return _timingLog(); }
-
- inline static std::ostream& detail() { return _detailLog(); }
-
- inline static std::ostream& result() { return _resultLog(); }
-
- inline static Log& debugLog() { return _debugLog; }
-
- inline static Log& errorLog() { return _errorLog; }
-
- inline static Log& timingLog() { return _timingLog; }
-
- inline static Log& detailLog() { return _detailLog; }
-
- inline static Log& resultLog() { return _resultLog; }
- inline std::ostream& operator() () {
- if (quiet) {
- return dummy;
- } else {
- return *target;
- }
- }
- inline void setQuiet(const bool _quiet = true) {
- quiet = _quiet;
- }
- private:
- static Log _debugLog;
- static Log _errorLog;
- static Log _timingLog;
- static Log _detailLog;
- static Log _resultLog;
- static std::stringstream dummy;
- std::ostream* target;
- bool quiet;
- };
- }
- #endif
|