Log.h
Go to the documentation of this file.
//-----------------------------------------------------------------------------
//
// Log.h
//
// Cross-platform message and error logging
//
// Copyright (c) 2010 Mal Lansell <mal@lansell.org>
// All rights reserved.
//
// SOFTWARE NOTICE AND LICENSE
//
// This file is part of OpenZWave.
//
// OpenZWave is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// OpenZWave is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
#ifndef _Log_H
#define _Log_H
#include <stdarg.h>
#include <string>
#include "Defs.h"
namespace OpenZWave
{
class Mutex;
extern char const *LogLevelString[];
enum LogLevel
{
LogLevel_Invalid,
LogLevel_None,
LogLevel_Always,
LogLevel_Fatal,
LogLevel_Error,
LogLevel_Warning,
LogLevel_Alert,
LogLevel_Info,
LogLevel_Detail,
LogLevel_Debug,
LogLevel_StreamDetail,
LogLevel_Internal
};
class i_LogImpl
{
public:
i_LogImpl() { } ;
virtual ~i_LogImpl() { } ;
virtual void Write( LogLevel _level, uint8 const _nodeId, char const* _format, va_list _args ) = 0;
virtual void QueueDump() = 0;
virtual void QueueClear() = 0;
virtual void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger ) = 0;
virtual void SetLogFileName( const string &_filename ) = 0;
};
class Log
{
public:
static Log* Create( string const& _filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel const _saveLevel, LogLevel const _queueLevel, LogLevel const _dumpTrigger );
static Log* Create( i_LogImpl *LogClass );
static void Destroy();
static bool SetLoggingClass(i_LogImpl *LogClass );
static void SetLoggingState(bool _dologging);
static void SetLoggingState( LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger );
static bool GetLoggingState();
static void GetLoggingState( LogLevel* _saveLevel, LogLevel* _queueLevel, LogLevel* _dumpTrigger );
static void SetLogFileName( const string &_filename );
static void Write( LogLevel _level, char const* _format, ... );
static void Write( LogLevel _level, uint8 const _nodeId, char const* _format, ... );
static void QueueDump();
static void QueueClear();
private:
Log( string const& _filename, bool const _bAppend, bool const _bConsoleOutput, LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger );
~Log();
static i_LogImpl* m_pImpl;
static Log* s_instance;
static bool s_customLogger;
Mutex* m_logMutex;
};
} // namespace OpenZWave
#endif //_Log_H
OpenZWave::LogLevel
LogLevel
Definition: Log.h:41
OpenZWave
Definition: Bitfield.h:34
OpenZWave::i_LogImpl::SetLoggingState
virtual void SetLoggingState(LogLevel _saveLevel, LogLevel _queueLevel, LogLevel _dumpTrigger)=0
OpenZWave::i_LogImpl::i_LogImpl
i_LogImpl()
Definition: Log.h:61
OpenZWave::i_LogImpl::QueueClear
virtual void QueueClear()=0
OpenZWave::LogLevel_Internal
Definition: Log.h:55
OpenZWave::i_LogImpl::QueueDump
virtual void QueueDump()=0
Defs.h
OpenZWave::LogLevel_Invalid
Definition: Log.h:43
OpenZWave::LogLevel_Error
Definition: Log.h:47
OpenZWave::LogLevelString
char const * LogLevelString[]
Definition: Log.cpp:45
OpenZWave::LogLevel_Always
Definition: Log.h:45
OpenZWave::i_LogImpl::Write
virtual void Write(LogLevel _level, uint8 const _nodeId, char const *_format, va_list _args)=0
OpenZWave::LogLevel_Fatal
Definition: Log.h:46
OpenZWave::i_LogImpl::~i_LogImpl
virtual ~i_LogImpl()
Definition: Log.h:62
OpenZWave::LogLevel_Warning
Definition: Log.h:48
OpenZWave::LogLevel_Alert
Definition: Log.h:49
OpenZWave::i_LogImpl::SetLogFileName
virtual void SetLogFileName(const string &_filename)=0
OpenZWave::LogLevel_Debug
Definition: Log.h:52
OpenZWave::Mutex
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition: Mutex.h:39
OpenZWave::LogLevel_Info
Definition: Log.h:50
OpenZWave::LogLevel_StreamDetail
Definition: Log.h:54
OpenZWave::i_LogImpl
Definition: Log.h:58
OpenZWave::LogLevel_Detail
Definition: Log.h:51
OpenZWave::Log
Implements a platform-independent log...written to the console and, optionally, a file...
Definition: Log.h:72
OpenZWave::LogLevel_None
Definition: Log.h:44
uint8
unsigned char uint8
Definition: Defs.h:74