source: pacpusframework/branches/2.0-beta1/src/PacpusLib/Log.cpp@ 132

Last change on this file since 132 was 89, checked in by morasjul, 12 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

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