OpenZWave Library 1.6.0
Loading...
Searching...
No Matches
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 "Defs.h"
34
35
36
37namespace OpenZWave
38{
39 class Mutex;
40 extern char const *LogLevelString[];
41
48 {
62 };
63
71 {
72 public:
73 i_LogImpl() { } ;
74 virtual ~i_LogImpl() { } ;
75 virtual void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args ) = 0;
76 virtual void QueueDump() = 0;
77 virtual void QueueClear() = 0;
78 virtual void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ) = 0;
79 virtual void SetLogFileName( const string &_filename ) = 0;
80 };
81
85 class Log
86 {
87 public:
95 static Log* Create( string const& _filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger );
96
106 static Log* Create( i_LogImpl *LogClass );
107
114 static void Destroy();
115
122 static bool SetLoggingClass(i_LogImpl *LogClass );
123
128 static void SetLoggingState(bool _dologging);
129
138 static void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger );
139
144 static bool GetLoggingState();
145
152 static void GetLoggingState( LogLevel* _saveLevel, LogLevel* _queueLevel, LogLevel* _dumpTrigger );
153
161 static void SetLogFileName( const string &_filename );
162
171 static void Write( LogLevel _level, char const* _format, ... );
172
182 static void Write( LogLevel _level, uint8 const _nodeId, char const* _format, ... );
183
186 static void QueueDump();
187
191 static void QueueClear();
192
193 private:
194 Log( string const& _filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger );
195 ~Log();
196
197 static i_LogImpl* m_pImpl;
198 static Log* s_instance;
199 static bool s_customLogger;
200 Mutex* m_logMutex;
201 };
202} // namespace OpenZWave
203
204#endif //_Log_H
unsigned char uint8
Definition Defs.h:89
Implements a platform-independent log...written to the console and, optionally, a file.
Definition Log.h:86
static void QueueClear()
Definition Log.cpp:286
static bool GetLoggingState()
Determine whether logging is enabled or not (retained for backward compatibility)
Definition Log.cpp:212
static void Write(LogLevel _level, char const *_format,...)
Write an entry to the log.
Definition Log.cpp:223
static void QueueDump()
Send the queued log messages to the log output.
Definition Log.cpp:270
static void Destroy()
Destroys the log.
Definition Log.cpp:122
static bool SetLoggingClass(i_LogImpl *LogClass)
Set the Logging Implementation Class to replace the standard File/Console logging.
Definition Log.cpp:134
static Log * Create(i_LogImpl *LogClass)
Create a log.
static void SetLoggingState(bool _dologging)
Enable or disable library logging (retained for backward compatibility)
Definition Log.cpp:156
static void GetLoggingState(LogLevel *_saveLevel, LogLevel *_queueLevel, LogLevel *_dumpTrigger)
Obtain the various logging levels.
static void SetLogFileName(const string &_filename)
Change the log file name.
Definition Log.cpp:302
static Log * Create(string const &_filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger)
Create a log.
Definition Log.cpp:74
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition Mutex.h:41
A Abstract class to create a Custom Logging Method.
Definition Log.h:71
virtual void QueueDump()=0
i_LogImpl()
Definition Log.h:73
virtual void SetLogFileName(const string &_filename)=0
virtual ~i_LogImpl()
Definition Log.h:74
virtual void Write(LogLevel _level, uint8 const _nodeId, char const *_format, va_list _args)=0
virtual void QueueClear()=0
virtual void SetLoggingState(LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger)=0
LogLevel
Various LogLevels available to the Application.
Definition Log.h:48
@ LogLevel_Fatal
Definition Log.h:52
@ LogLevel_Warning
Definition Log.h:54
@ LogLevel_None
Definition Log.h:50
@ LogLevel_Alert
Definition Log.h:55
@ LogLevel_StreamDetail
Definition Log.h:60
@ LogLevel_Error
Definition Log.h:53
@ LogLevel_Info
Definition Log.h:56
@ LogLevel_Internal
Definition Log.h:61
@ LogLevel_Always
Definition Log.h:51
@ LogLevel_Debug
Definition Log.h:58
@ LogLevel_Invalid
Definition Log.h:49
@ LogLevel_Detail
Definition Log.h:57
Definition Bitfield.h:35
char const * LogLevelString[]
Definition Log.cpp:45