OpenZWave Library  1.6.962
Log.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // Log.h
4 //
5 // Cross-platform message and error logging
6 //
7 // Copyright (c) 2010 Mal Lansell <mal@lansell.org>
8 // All rights reserved.
9 //
10 // SOFTWARE NOTICE AND LICENSE
11 //
12 // This file is part of OpenZWave.
13 //
14 // OpenZWave is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU Lesser General Public License as published
16 // by the Free Software Foundation, either version 3 of the License,
17 // or (at your option) any later version.
18 //
19 // OpenZWave is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU Lesser General Public License for more details.
23 //
24 // You should have received a copy of the GNU Lesser General Public License
25 // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
26 //
27 //-----------------------------------------------------------------------------
28 #ifndef _Log_H
29 #define _Log_H
30 
31 #include <stdarg.h>
32 #include <string>
33 #include <vector>
34 #include "Defs.h"
35 
36 namespace OpenZWave
37 {
38  namespace Internal
39  {
40  namespace Platform
41  {
42  class Mutex;
43  }
44  }
45  extern char const *LogLevelString[];
46 
52  enum LogLevel
53  {
67  };
68 
75  class i_LogImpl
76  {
77  public:
79  {
80  }
81  ;
82  virtual ~i_LogImpl()
83  {
84  }
85  ;
86  virtual void Write(LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args) = 0;
87  virtual void QueueDump() = 0;
88  virtual void QueueClear() = 0;
89  virtual void SetLoggingState(LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger) = 0;
90  virtual void SetLogFileName(const string &_filename) = 0;
91  };
92 
97  {
98  public:
106  static Log* Create(string const& _filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger);
107 
117  static Log* Create(i_LogImpl *LogClass);
118 
125  static void Destroy();
126 
135  static bool SetLoggingClass(i_LogImpl *LogClass, bool Append = false);
136 
141  static void SetLoggingState(bool _dologging);
142 
151  static void SetLoggingState(LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger);
152 
157  static bool GetLoggingState();
158 
165  static void GetLoggingState(LogLevel* _saveLevel, LogLevel* _queueLevel, LogLevel* _dumpTrigger);
166 
174  static void SetLogFileName(const string &_filename);
175 
184  static void Write(LogLevel _level, char const* _format, ...);
185 
195  static void Write(LogLevel _level, uint8 const _nodeId, char const* _format, ...);
196 
199  static void QueueDump();
200 
204  static void QueueClear();
205 
206  private:
207  Log(string const& _filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger);
208  ~Log();
209 
210  static std::vector<i_LogImpl*> m_pImpls;
211  static Log* s_instance;
212  Internal::Platform::Mutex* m_logMutex;
213  };
214 } // namespace OpenZWave
215 
216 #endif //_Log_H
Definition: Log.h:56
Definition: Log.h:60
Definition: Bitfield.cpp:30
LogLevel
Various LogLevels available to the Application.
Definition: Log.h:52
virtual void SetLoggingState(LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger)=0
#define OPENZWAVE_EXPORT
Definition: Defs.h:52
Definition: Log.h:61
Definition: Log.h:54
i_LogImpl()
Definition: Log.h:78
virtual void QueueClear()=0
Definition: Log.h:62
virtual void QueueDump()=0
Definition: Log.h:57
Definition: Log.h:59
char const * LogLevelString[]
Definition: Log.cpp:44
virtual void Write(LogLevel _level, uint8 const _nodeId, char const *_format, va_list _args)=0
virtual ~i_LogImpl()
Definition: Log.h:82
virtual void SetLogFileName(const string &_filename)=0
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:44
Definition: Log.h:66
A Abstract class to create a Custom Logging MethodUse this as the basis to create a custom logging cl...
Definition: Log.h:75
Definition: Log.h:63
Definition: Log.h:58
Implements a platform-independent log...written to the console and, optionally, a file.
Definition: Log.h:96
Definition: Log.h:55
unsigned char uint8
Definition: Defs.h:85