| 1 | < | #pragma once | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 2 | < | #include <plog/Logger.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 3 | < | #include <plog/Formatters/CsvFormatter.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 4 | < | #include <plog/Formatters/TxtFormatter.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 5 | < | #include <plog/Appenders/RollingFileAppender.h> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 6 | < | #include <cstring> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 7 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 8 | < | namespace plog | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 9 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 10 | < | namespace | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 11 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 12 | < | bool isCsv(const util::nchar* fileName) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 13 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 14 | < | const util::nchar* dot = util::findExtensionDot(fileName); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 15 | < | #ifdef _WIN32 | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 16 | < | return dot && 0 == std::wcscmp(dot, L".csv"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 17 | < | #else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 18 | < | return dot && 0 == std::strcmp(dot, ".csv"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 19 | < | #endif | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 20 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 21 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 22 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 23 | < | ////////////////////////////////////////////////////////////////////////// | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 24 | < | // Empty initializer / one appender | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 25 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 26 | < | template<int instance> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 27 | < | inline Logger<instance>& init(Severity maxSeverity = none, IAppender* appender = NULL) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 28 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 29 | < | static Logger<instance> logger(maxSeverity); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 30 | < | return appender ? logger.addAppender(appender) : logger; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 33 | < | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity = none, IAppender* appender = NULL) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 34 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 35 | < | return init<PLOG_DEFAULT_INSTANCE>(maxSeverity, appender); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 36 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 37 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 38 | < | ////////////////////////////////////////////////////////////////////////// | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 39 | < | // RollingFileAppender with any Formatter | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 40 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 41 | < | template<class Formatter, int instance> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 | < | inline Logger<instance>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 43 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 44 | < | static RollingFileAppender<Formatter> rollingFileAppender(fileName, maxFileSize, maxFiles); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 45 | < | return init<instance>(maxSeverity, &rollingFileAppender); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 46 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 47 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 | < | template<class Formatter> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 | < | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 | < | return init<Formatter, PLOG_DEFAULT_INSTANCE>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 53 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 54 | < | ////////////////////////////////////////////////////////////////////////// | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 55 | < | // RollingFileAppender with TXT/CSV chosen by file extension | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 56 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 57 | < | template<int instance> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 58 | < | inline Logger<instance>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 59 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 60 | < | return isCsv(fileName) ? init<CsvFormatter, instance>(maxSeverity, fileName, maxFileSize, maxFiles) : init<TxtFormatter, instance>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 61 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 62 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 63 | < | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 64 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 65 | < | return init<PLOG_DEFAULT_INSTANCE>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 66 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 67 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 68 | < | ////////////////////////////////////////////////////////////////////////// | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 69 | < | // CHAR variants for Windows | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 70 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 71 | < | #ifdef _WIN32 | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 72 | < | template<class Formatter, int instance> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 73 | < | inline Logger<instance>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 74 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 75 | < | return init<Formatter, instance>(maxSeverity, util::toWide(fileName).c_str(), maxFileSize, maxFiles); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 76 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 77 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 78 | < | template<class Formatter> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 79 | < | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | < | return init<Formatter, PLOG_DEFAULT_INSTANCE>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 83 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 84 | < | template<int instance> | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 85 | < | inline Logger<instance>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 86 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 87 | < | return init<instance>(maxSeverity, util::toWide(fileName).c_str(), maxFileSize, maxFiles); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 88 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 89 | < |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 90 | < | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 91 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 92 | < | return init<PLOG_DEFAULT_INSTANCE>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 94 | < | #endif | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 95 | < | } | 
 
 
 
 
 
 
 
 
 | 1 | > | #pragma once | 
 
 
 
 
 | 2 | > | #include <plog/Logger.h> | 
 
 
 
 
 | 3 | > | #include <plog/Formatters/CsvFormatter.h> | 
 
 
 
 
 | 4 | > | #include <plog/Formatters/TxtFormatter.h> | 
 
 
 
 
 | 5 | > | #include <plog/Appenders/RollingFileAppender.h> | 
 
 
 
 
 | 6 | > | #include <cstring> | 
 
 
 
 
 | 7 | > |  | 
 
 
 
 
 | 8 | > | namespace plog | 
 
 
 
 
 | 9 | > | { | 
 
 
 
 
 | 10 | > | namespace | 
 
 
 
 
 | 11 | > | { | 
 
 
 
 
 | 12 | > | bool isCsv(const util::nchar* fileName) | 
 
 
 
 
 | 13 | > | { | 
 
 
 
 
 | 14 | > | const util::nchar* dot = util::findExtensionDot(fileName); | 
 
 
 
 
 | 15 | > | #ifdef _WIN32 | 
 
 
 
 
 | 16 | > | return dot && 0 == std::wcscmp(dot, L".csv"); | 
 
 
 
 
 | 17 | > | #else | 
 
 
 
 
 | 18 | > | return dot && 0 == std::strcmp(dot, ".csv"); | 
 
 
 
 
 | 19 | > | #endif | 
 
 
 
 
 | 20 | > | } | 
 
 
 
 
 | 21 | > | } | 
 
 
 
 
 | 22 | > |  | 
 
 
 
 
 | 23 | > | ////////////////////////////////////////////////////////////////////////// | 
 
 
 
 
 | 24 | > | // Empty initializer / one appender | 
 
 
 
 
 | 25 | > |  | 
 
 
 
 
 | 26 | > | template<int instance> | 
 
 
 
 
 | 27 | > | inline Logger<instance>& init(Severity maxSeverity = none, IAppender* appender = NULL) | 
 
 
 
 
 | 28 | > | { | 
 
 
 
 
 | 29 | > | static Logger<instance> logger(maxSeverity); | 
 
 
 
 
 | 30 | > | return appender ? logger.addAppender(appender) : logger; | 
 
 
 
 
 | 31 | > | } | 
 
 
 
 
 | 32 | > |  | 
 
 
 
 
 | 33 | > | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity = none, IAppender* appender = NULL) | 
 
 
 
 
 | 34 | > | { | 
 
 
 
 
 | 35 | > | return init<PLOG_DEFAULT_INSTANCE>(maxSeverity, appender); | 
 
 
 
 
 | 36 | > | } | 
 
 
 
 
 | 37 | > |  | 
 
 
 
 
 | 38 | > | ////////////////////////////////////////////////////////////////////////// | 
 
 
 
 
 | 39 | > | // RollingFileAppender with any Formatter | 
 
 
 
 
 | 40 | > |  | 
 
 
 
 
 | 41 | > | template<class Formatter, int instance> | 
 
 
 
 
 | 42 | > | inline Logger<instance>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 | 43 | > | { | 
 
 
 
 
 | 44 | > | static RollingFileAppender<Formatter> rollingFileAppender(fileName, maxFileSize, maxFiles); | 
 
 
 
 
 | 45 | > | return init<instance>(maxSeverity, &rollingFileAppender); | 
 
 
 
 
 | 46 | > | } | 
 
 
 
 
 | 47 | > |  | 
 
 
 
 
 | 48 | > | template<class Formatter> | 
 
 
 
 
 | 49 | > | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 | 50 | > | { | 
 
 
 
 
 | 51 | > | return init<Formatter, PLOG_DEFAULT_INSTANCE>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 | 52 | > | } | 
 
 
 
 
 | 53 | > |  | 
 
 
 
 
 | 54 | > | ////////////////////////////////////////////////////////////////////////// | 
 
 
 
 
 | 55 | > | // RollingFileAppender with TXT/CSV chosen by file extension | 
 
 
 
 
 | 56 | > |  | 
 
 
 
 
 | 57 | > | template<int instance> | 
 
 
 
 
 | 58 | > | inline Logger<instance>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 | 59 | > | { | 
 
 
 
 
 | 60 | > | return isCsv(fileName) ? init<CsvFormatter, instance>(maxSeverity, fileName, maxFileSize, maxFiles) : init<TxtFormatter, instance>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 | 61 | > | } | 
 
 
 
 
 | 62 | > |  | 
 
 
 
 
 | 63 | > | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity, const util::nchar* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 | 64 | > | { | 
 
 
 
 
 | 65 | > | return init<PLOG_DEFAULT_INSTANCE>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 | 66 | > | } | 
 
 
 
 
 | 67 | > |  | 
 
 
 
 
 | 68 | > | ////////////////////////////////////////////////////////////////////////// | 
 
 
 
 
 | 69 | > | // CHAR variants for Windows | 
 
 
 
 
 | 70 | > |  | 
 
 
 
 
 | 71 | > | #ifdef _WIN32 | 
 
 
 
 
 | 72 | > | template<class Formatter, int instance> | 
 
 
 
 
 | 73 | > | inline Logger<instance>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 | 74 | > | { | 
 
 
 
 
 | 75 | > | return init<Formatter, instance>(maxSeverity, util::toWide(fileName).c_str(), maxFileSize, maxFiles); | 
 
 
 
 
 | 76 | > | } | 
 
 
 
 
 | 77 | > |  | 
 
 
 
 
 | 78 | > | template<class Formatter> | 
 
 
 
 
 | 79 | > | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 | 80 | > | { | 
 
 
 
 
 | 81 | > | return init<Formatter, PLOG_DEFAULT_INSTANCE>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 | 82 | > | } | 
 
 
 
 
 | 83 | > |  | 
 
 
 
 
 | 84 | > | template<int instance> | 
 
 
 
 
 | 85 | > | inline Logger<instance>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 | 86 | > | { | 
 
 
 
 
 | 87 | > | return init<instance>(maxSeverity, util::toWide(fileName).c_str(), maxFileSize, maxFiles); | 
 
 
 
 
 | 88 | > | } | 
 
 
 
 
 | 89 | > |  | 
 
 
 
 
 | 90 | > | inline Logger<PLOG_DEFAULT_INSTANCE>& init(Severity maxSeverity, const char* fileName, size_t maxFileSize = 0, int maxFiles = 0) | 
 
 
 
 
 | 91 | > | { | 
 
 
 
 
 | 92 | > | return init<PLOG_DEFAULT_INSTANCE>(maxSeverity, fileName, maxFileSize, maxFiles); | 
 
 
 
 
 | 93 | > | } | 
 
 
 
 
 | 94 | > | #endif | 
 
 
 
 
 | 95 | > | } |