NullLogger.h
1 /**************************************************************************************
2 Copyright 2015 Applied Research Associates, Inc.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the License
5 at:
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software distributed under
8 the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9 CONDITIONS OF ANY KIND, either express or implied. See the License for the
10 specific language governing permissions and limitations under the License.
11 **************************************************************************************/
12 
13 #pragma once
14 #include <sstream>
15 
16 #pragma warning(push)
17 #pragma warning(disable : 4512) // assignment operator could not be generated
18 #pragma warning(disable : 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
19 #include <log4cpp/Category.hh>
20 #pragma warning(pop)
21 
22 #include <biogears/cdm/utils/Logger.h>
23 #include <biogears/cdm/CommonDataModel.h>
24 
25 namespace biogears {
26 class NullLogger;
27 
28 #pragma warning(push)
29 #pragma warning(disable : 4100)
30 #pragma warning(pop)
31 
32 class BIOGEARS_API NullLogger : public Logger {
33 public:
34  NullLogger(const std::string& logFilename = Loggable::empty);
35  virtual ~NullLogger();
36 
37  void LogToConsole(bool b);
38 
39  void ResetLogFile(const std::string& logFilename = Loggable::empty);
40 
41  void SetLogLevel(log4cpp::Priority::Value priority);
42  log4cpp::Priority::Value GetLogLevel();
43 
44  virtual void SetLogTime(const SEScalarTime* time);
45 
46  virtual void SetForward(LoggerForward* forward);
47  virtual bool HasForward();
48 
49  virtual void Debug(const std::string& msg, const std::string& origin = Loggable::empty);
50  virtual void Debug(std::stringstream& msg, const std::string& origin = Loggable::empty);
51  virtual void Debug(std::ostream& msg, const std::string& origin = Loggable::empty);
52 
53  virtual void Info(const std::string& msg, const std::string& origin = Loggable::empty);
54  virtual void Info(std::stringstream& msg, const std::string& origin = Loggable::empty);
55  virtual void Info(const std::stringstream& msg, const std::string& origin = Loggable::empty);
56  virtual void Info(std::ostream& msg, const std::string& origin = Loggable::empty);
57 
58  virtual void Warning(const std::string& msg, const std::string& origin = Loggable::empty);
59  virtual void Warning(std::stringstream& msg, const std::string& origin = Loggable::empty);
60  virtual void Warning(std::ostream& msg, const std::string& origin = Loggable::empty);
61 
62  virtual void Error(const std::string& msg, const std::string& origin = Loggable::empty);
63  virtual void Error(std::stringstream& msg, const std::string& origin = Loggable::empty);
64  virtual void Error(std::ostream& msg, const std::string& origin = Loggable::empty);
65 
66  virtual void Fatal(const std::string& msg, const std::string& origin = Loggable::empty);
67  virtual void Fatal(std::stringstream& msg, const std::string& origin = Loggable::empty);
68  virtual void Fatal(std::ostream& msg, const std::string& origin = Loggable::empty);
69 
70 protected:
71  virtual std::string FormatLogMessage(const std::string& origin, const std::string& msg);
72 
74  log4cpp::Category* m_Log;
75  log4cpp::Appender* m_FileAppender;
76  log4cpp::Appender* m_ConsoleAppender;
78  std::stringstream m_ss;
79 };
80 }
std::stringstream m_ss
Definition: NullLogger.h:78
Definition: NullLogger.h:32
static const std::string empty
Definition: Logger.h:29
const SEScalarTime * m_time
Definition: NullLogger.h:77
log4cpp::Category * m_Log
Definition: NullLogger.h:74
Definition: Logger.h:75
Definition: Logger.h:64
Definition: SEScalarTime.h:37
LoggerForward * m_Forward
Definition: NullLogger.h:73
log4cpp::Appender * m_ConsoleAppender
Definition: NullLogger.h:76
log4cpp::Appender * m_FileAppender
Definition: NullLogger.h:75
Definition: SEElectricalCircuit.h:18