source: pacpusframework/trunk/src/PacpusLib/Log.cpp@ 11

Last change on this file since 11 was 3, checked in by sgosseli, 12 years ago
  • Add the existing Pacpus files from pacpusdev and pacpuscore.
  • Provide a clean build system based on multiple CMake files.
File size: 1.6 KB
Line 
1#include "kernel/Log.h"
2
3#ifdef PACPUS_USE_LOG
4
5#ifdef _MSC_VER
6# pragma warning(push)
7# pragma warning(disable: 4231 4251)
8#endif // _MSC_VER
9
10#include <log4cxx/basicconfigurator.h>
11#include <log4cxx/consoleappender.h>
12#include <log4cxx/patternlayout.h>
13#include <log4cxx/propertyconfigurator.h>
14#include <QString>
15
16#ifdef _MSC_VER
17# pragma warning(pop)
18#endif // _MSC_VER
19
20using namespace log4cxx;
21
22namespace pacpus {
23
24static int niftyCounter;
25
26LogConfigurator::LogConfigurator()
27{
28 using namespace log4cxx;
29
30 if (0 == niftyCounter++) {
31 BasicConfigurator::resetConfiguration();
32
33 LayoutPtr lp(new PatternLayout(LOG4CXX_STR("%-6r [%-5p] %30.30c - %m%n")));
34 AppenderPtr ap(new ConsoleAppender(lp));
35 BasicConfigurator::configure(ap);
36 Logger::getRootLogger()->setLevel(log4cxx::Level::getInfo());
37 }
38}
39
40LogConfigurator::~LogConfigurator()
41{
42 if (0 == --niftyCounter) {
43 // clean up
44 }
45}
46
47void LogConfigurator::configureLoggerWithFile(const char * configFilename)
48{
49 BasicConfigurator::resetConfiguration();
50 PropertyConfigurator::configure(configFilename);
51}
52
53} // namespace pacpus
54
55helpers::CharMessageBuffer & operator<<(helpers::CharMessageBuffer & os, const QString & val)
56{
57 return os << val.toStdString();
58}
59
60helpers::CharMessageBuffer & operator<<(helpers::MessageBuffer & os, const QString & val)
61{
62 return os << val.toStdString();
63}
64
65#else // PACPUS_USE_LOG
66
67namespace pacpus {
68
69LogConfigurator::LogConfigurator()
70{
71}
72
73LogConfigurator::~LogConfigurator()
74{
75}
76
77void LogConfigurator::configureLoggerWithFile(const char * /*configFilename*/)
78{
79}
80
81} // namespace pacpus
82
83#endif // PACPUS_USE_LOG
Note: See TracBrowser for help on using the repository browser.