1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #pragma once
#include <Message_PrinterOStream.hxx> #include <Message.hxx> #include <TCollection_AsciiString.hxx> #include <string>
class Message_PrinterWithTimestamp : public Message_PrinterOStream { public: Message_PrinterWithTimestamp(const char* const theFileName, const bool theDoAppend, const Message_Gravity theTraceLevel = Message_Info); protected: void send(const TCollection_AsciiString& theString, const Message_Gravity theGravity) const override; };
class Logger { public: Logger() = delete; static void init(const char* fileName, bool doAppend, Message_Gravity traceLevel); static void Trace(const std::string& message, const char* file, int line, bool includeLocation = false); static void Info(const std::string& message, const char* file, int line, bool includeLocation = false); static void Warning(const std::string& message, const char* file, int line, bool includeLocation = false); static void Alarm(const std::string& message, const char* file, int line, bool includeLocation = false); static void Fail(const std::string& message, const char* file, int line, bool includeLocation = false); };
#define LOG_TRACE(msg) Logger::Trace((msg), __FILE__, __LINE__) #define LOG_INFO(msg) Logger::Info((msg), __FILE__, __LINE__) #define LOG_WARNING(msg) Logger::Warning((msg), __FILE__, __LINE__) #define LOG_ALARM(msg) Logger::Alarm((msg), __FILE__, __LINE__) #define LOG_FAIL(msg) Logger::Fail((msg), __FILE__, __LINE__)
#define LOG_TRACE_LOC(msg) Logger::Trace((msg), __FILE__, __LINE__, true) #define LOG_INFO_LOC(msg) Logger::Info((msg), __FILE__, __LINE__, true) #define LOG_WARNING_LOC(msg) Logger::Warning((msg), __FILE__, __LINE__, true) #define LOG_ALARM_LOC(msg) Logger::Alarm((msg), __FILE__, __LINE__, true) #define LOG_FAIL_LOC(msg) Logger::Fail((msg), __FILE__, __LINE__, true)
|