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

Last change on this file since 63 was 62, checked in by Marek Kurdej, 12 years ago

Update: license info.

File size: 1.8 KB
Line 
1// This file is part of the PACPUS framework distributed under the
2// CECILL-C License, Version 1.0.
3//
4/// @version $Id$
5
6#include <Pacpus/kernel/Log.h>
7
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
25using namespace log4cxx;
26
27namespace pacpus {
28
29static int niftyCounter;
30
31LogConfigurator::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
45LogConfigurator::~LogConfigurator()
46{
47 if (0 == --niftyCounter) {
48 // clean up
49 }
50}
51
52void LogConfigurator::configureLoggerWithFile(const char * configFilename)
53{
54 BasicConfigurator::resetConfiguration();
55 PropertyConfigurator::configure(configFilename);
56}
57
58} // namespace pacpus
59
60helpers::CharMessageBuffer & operator<<(helpers::CharMessageBuffer & os, const QString & val)
61{
62 return os << val.toStdString();
63}
64
65helpers::CharMessageBuffer & operator<<(helpers::MessageBuffer & os, const QString & val)
66{
67 return os << val.toStdString();
68}
69
70#else // PACPUS_USE_LOG
71
72namespace pacpus {
73
74LogConfigurator::LogConfigurator()
75{
76}
77
78LogConfigurator::~LogConfigurator()
79{
80}
81
82void LogConfigurator::configureLoggerWithFile(const char * /*configFilename*/)
83{
84}
85
86} // namespace pacpus
87
88#endif // PACPUS_USE_LOG
Note: See TracBrowser for help on using the repository browser.