/* libzz
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2000-2006, Toni Thomsson <toni@tonjac.org>
*/
#ifndef zz_log_h
#define zz_log_h
#include <rislog.h>
#include <zz_string.h>
#include <zz_export.h>
#ifdef _WIN32
#include <zz_win_threadmutex.h>
#endif
// Description: Info (logga info som är bra för driftspersonal)
#define _INFOPARAMS LL_INFO , 0, __LINE__, __FILE__
// Description: Trace (logga in/ut i funktioner)
#define _TRACEPARAMS LL_TRACE , 0, __LINE__, __FILE__
// Description: Debug (logga innehåll i variabler)
#define _DEBUGPARAMS LL_DEBUG , 0, __LINE__, __FILE__
// Description: Warning (logga varningar ej fel)
#define _WARNINGPARAMS LL_WARNING, 0, __LINE__, __FILE__
#ifndef _LAF
// Description: Macro för radnummer + filnamn
#define _LAF __LINE__, __FILE__
#endif
/**
Logger.
<pre>
;Sample configuration file:
[Default]
;Level can be:
;0-Trace, 1-Debug, 2-Info, 3-Warning, 4-Error
level=0
;destination can be:
;0-Messagebox, 1-File, 2-Debug console, 4-Stderr, 5-Eventlog, 6-NULL
destination=1
filename=..\logs\default.log
lock=0
[Myname]
level=2
destination=5
filename=..\logs\myname.log
lock=0
</pre>
@author Toni Thomsson, toni@tonjac.org
*/
class ZZ_API CzzLog
{
public:
/**
Create a logger with the name "default"
*/
CzzLog( void );
/**
Create a logger. Use log.ini in current directory
to configure log.
@param app Name
*/
CzzLog( const CzzString& app );
/**
Create a logger
@param app Name
@param ini Path to configuration file
*/
CzzLog( const CzzString& app, const CzzString& ini );
/**
Copy constructor
*/
CzzLog( CzzLog& obj );
~CzzLog();
/**
Log a message. You can use the following macros for
the three first arguments:
_DEBUGPARAMS, _TRACEPARAMS, _INFOPARAMS, _WARNINGPARAMS.
Use LL_ERROR for errors.
@param Level Loglevel
@param ErrorCode Error code
@param Row Line number
@param Module File or module
@param Message Message/format, see printf()
@param ... arguments to format string, see printf()
@see CzzLogException
*/
LOGRET Print( const LOGLEVEL Level,
const int ErrorCode,
const int Row,
const char* Module,
const char* Message,
... );
/** Log handle */
HLOG GetHandle();
private:
void Init( const CzzString& app );
void Init( const CzzString& app, const CzzString& ini );
static HLOG m_Handle;
static short m_cRefs;
#ifdef _WIN32
static CzzWinThreadMutex m_Mutex;
#endif
};
#endif