| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #ifndef BASE_CONSOLEOBSERVER_H
|
| | #define BASE_CONSOLEOBSERVER_H
|
| |
|
| | #include <Base/Console.h>
|
| | #include <Base/Stream.h>
|
| |
|
| |
|
| | namespace Base
|
| | {
|
| |
|
| |
|
| |
|
| |
|
| | |
| | |
| |
|
| | class BaseExport ConsoleObserverFile: public ILogger
|
| | {
|
| | public:
|
| | explicit ConsoleObserverFile(const char* sFileName);
|
| | ~ConsoleObserverFile() override;
|
| |
|
| | void sendLog(
|
| | const std::string& notifiername,
|
| | const std::string& msg,
|
| | LogStyle level,
|
| | IntendedRecipient recipient,
|
| | ContentType content
|
| | ) override;
|
| | const char* name() override
|
| | {
|
| | return "File";
|
| | }
|
| |
|
| | ConsoleObserverFile(const ConsoleObserverFile&) = delete;
|
| | ConsoleObserverFile(ConsoleObserverFile&&) = delete;
|
| | ConsoleObserverFile& operator=(const ConsoleObserverFile&) = delete;
|
| | ConsoleObserverFile& operator=(ConsoleObserverFile&&) = delete;
|
| |
|
| | private:
|
| | Base::ofstream cFileStream;
|
| | };
|
| |
|
| | |
| | |
| |
|
| | class BaseExport ConsoleObserverStd: public ILogger
|
| | {
|
| | public:
|
| | ConsoleObserverStd();
|
| | ~ConsoleObserverStd() override;
|
| | void sendLog(
|
| | const std::string& notifiername,
|
| | const std::string& msg,
|
| | LogStyle level,
|
| | IntendedRecipient recipient,
|
| | ContentType content
|
| | ) override;
|
| | const char* name() override
|
| | {
|
| | return "Console";
|
| | }
|
| |
|
| | ConsoleObserverStd(const ConsoleObserverStd&) = delete;
|
| | ConsoleObserverStd(ConsoleObserverStd&&) = delete;
|
| | ConsoleObserverStd& operator=(const ConsoleObserverStd&) = delete;
|
| | ConsoleObserverStd& operator=(ConsoleObserverStd&&) = delete;
|
| |
|
| | private:
|
| | bool useColorStderr;
|
| | void Warning(const char* sWarn);
|
| | void Message(const char* sMsg);
|
| | void Error(const char* sErr);
|
| | void Log(const char* sLog);
|
| | void Critical(const char* sCritical);
|
| | };
|
| |
|
| | |
| | |
| | |
| |
|
| | class BaseExport ILoggerBlocker
|
| | {
|
| | public:
|
| |
|
| |
|
| | inline explicit ILoggerBlocker(
|
| | const char* co,
|
| | ConsoleMsgFlags msgTypes = ConsoleSingleton::MsgType_Txt | ConsoleSingleton::MsgType_Log
|
| | | ConsoleSingleton::MsgType_Wrn | ConsoleSingleton::MsgType_Err
|
| | | ConsoleSingleton::MsgType_Critical | ConsoleSingleton::MsgType_Notification
|
| | );
|
| |
|
| | ILoggerBlocker(ILoggerBlocker const&) = delete;
|
| | ILoggerBlocker(ILoggerBlocker const&&) = delete;
|
| |
|
| | ILoggerBlocker& operator=(ILoggerBlocker const&) = delete;
|
| | ILoggerBlocker& operator=(ILoggerBlocker const&&) = delete;
|
| |
|
| | inline ~ILoggerBlocker();
|
| |
|
| | private:
|
| | ConsoleMsgFlags msgTypesBlocked = 0;
|
| | const char* conObs;
|
| | };
|
| |
|
| | ILoggerBlocker::ILoggerBlocker(const char* co, ConsoleMsgFlags msgTypes)
|
| | : conObs(co)
|
| | {
|
| | msgTypesBlocked = Console().setEnabledMsgType(conObs, msgTypes, false);
|
| | }
|
| |
|
| | ILoggerBlocker::~ILoggerBlocker()
|
| | {
|
| | try {
|
| | #ifdef FC_DEBUG
|
| | auto debug = Console().setEnabledMsgType(conObs, msgTypesBlocked, true);
|
| | if (debug != msgTypesBlocked) {
|
| | Console().warning("Enabled message types have been changed while ILoggerBlocker was set\n");
|
| | }
|
| | #else
|
| | Console().setEnabledMsgType(conObs, msgTypesBlocked, true);
|
| | #endif
|
| | }
|
| | catch (...) {
|
| | }
|
| | }
|
| |
|
| | class BaseExport RedirectStdOutput: public std::streambuf
|
| | {
|
| | public:
|
| | RedirectStdOutput();
|
| |
|
| | protected:
|
| | int overflow(int ch = EOF) override;
|
| | int sync() override;
|
| |
|
| | private:
|
| | std::string buffer;
|
| | };
|
| |
|
| | class BaseExport RedirectStdError: public std::streambuf
|
| | {
|
| | public:
|
| | RedirectStdError();
|
| |
|
| | protected:
|
| | int overflow(int ch = EOF) override;
|
| | int sync() override;
|
| |
|
| | private:
|
| | std::string buffer;
|
| | };
|
| |
|
| | class BaseExport RedirectStdLog: public std::streambuf
|
| | {
|
| | public:
|
| | RedirectStdLog();
|
| |
|
| | protected:
|
| | int overflow(int ch = EOF) override;
|
| | int sync() override;
|
| |
|
| | private:
|
| | std::string buffer;
|
| | };
|
| |
|
| |
|
| | }
|
| |
|
| | #endif
|
| |
|