[62] | 1 | // This file is part of the PACPUS framework distributed under the
|
---|
| 2 | // CECILL-C License, Version 1.0.
|
---|
| 3 | //
|
---|
| 4 | /// @version $Id: Log.cpp 64 2013-01-09 16:41:12Z kurdejma $
|
---|
[3] | 5 |
|
---|
[31] | 6 | #include <Pacpus/kernel/Log.h>
|
---|
| 7 |
|
---|
[3] | 8 | #ifdef PACPUS_USE_LOG
|
---|
| 9 |
|
---|
| 10 | #ifdef _MSC_VER
|
---|
| 11 | # pragma warning(push)
|
---|
| 12 | # pragma warning(disable: 4231 4251)
|
---|
| 13 | #endif // _MSC_VER
|
---|
| 14 |
|
---|
| 15 | #include <log4cxx/basicconfigurator.h>
|
---|
| 16 | #include <log4cxx/consoleappender.h>
|
---|
| 17 | #include <log4cxx/patternlayout.h>
|
---|
| 18 | #include <log4cxx/propertyconfigurator.h>
|
---|
| 19 | #include <QString>
|
---|
| 20 |
|
---|
| 21 | #ifdef _MSC_VER
|
---|
| 22 | # pragma warning(pop)
|
---|
| 23 | #endif // _MSC_VER
|
---|
| 24 |
|
---|
| 25 | using namespace log4cxx;
|
---|
| 26 |
|
---|
| 27 | namespace pacpus {
|
---|
| 28 |
|
---|
| 29 | static int niftyCounter;
|
---|
| 30 |
|
---|
| 31 | LogConfigurator::LogConfigurator()
|
---|
| 32 | {
|
---|
| 33 | using namespace log4cxx;
|
---|
| 34 |
|
---|
| 35 | if (0 == niftyCounter++) {
|
---|
| 36 | BasicConfigurator::resetConfiguration();
|
---|
| 37 |
|
---|
| 38 | LayoutPtr lp(new PatternLayout(LOG4CXX_STR("%-6r [%-5p] %30.30c - %m%n")));
|
---|
| 39 | AppenderPtr ap(new ConsoleAppender(lp));
|
---|
| 40 | BasicConfigurator::configure(ap);
|
---|
| 41 | Logger::getRootLogger()->setLevel(log4cxx::Level::getInfo());
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | LogConfigurator::~LogConfigurator()
|
---|
| 46 | {
|
---|
| 47 | if (0 == --niftyCounter) {
|
---|
| 48 | // clean up
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | void LogConfigurator::configureLoggerWithFile(const char * configFilename)
|
---|
| 53 | {
|
---|
| 54 | BasicConfigurator::resetConfiguration();
|
---|
| 55 | PropertyConfigurator::configure(configFilename);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | } // namespace pacpus
|
---|
| 59 |
|
---|
| 60 | helpers::CharMessageBuffer & operator<<(helpers::CharMessageBuffer & os, const QString & val)
|
---|
| 61 | {
|
---|
| 62 | return os << val.toStdString();
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | helpers::CharMessageBuffer & operator<<(helpers::MessageBuffer & os, const QString & val)
|
---|
| 66 | {
|
---|
| 67 | return os << val.toStdString();
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | #else // PACPUS_USE_LOG
|
---|
| 71 |
|
---|
| 72 | namespace pacpus {
|
---|
| 73 |
|
---|
| 74 | LogConfigurator::LogConfigurator()
|
---|
| 75 | {
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | LogConfigurator::~LogConfigurator()
|
---|
| 79 | {
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | void LogConfigurator::configureLoggerWithFile(const char * /*configFilename*/)
|
---|
| 83 | {
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | } // namespace pacpus
|
---|
| 87 |
|
---|
| 88 | #endif // PACPUS_USE_LOG
|
---|