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

Last change on this file since 152 was 91, checked in by DHERBOMEZ Gérald, 11 years ago

Improvement of the build system to avoid some workarounds

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