2008-02-22 11:22:22 +01:00
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
/* Copyright (C) 2008 Jonathan Moore Liles */
|
|
|
|
/* */
|
|
|
|
/* This program is free software; you can redistribute it and/or modify it */
|
|
|
|
/* under the terms of the GNU General Public License as published by the */
|
|
|
|
/* Free Software Foundation; either version 2 of the License, or (at your */
|
|
|
|
/* option) any later version. */
|
|
|
|
/* */
|
|
|
|
/* This program 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 General Public License for */
|
|
|
|
/* more details. */
|
|
|
|
/* */
|
|
|
|
/* You should have received a copy of the GNU General Public License along */
|
|
|
|
/* with This program; see the file COPYING. If not,write to the Free Software */
|
|
|
|
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
/* Master class for journaling. */
|
|
|
|
|
2008-02-22 12:44:35 +01:00
|
|
|
#pragma once
|
|
|
|
|
2008-02-22 21:20:44 +01:00
|
|
|
#include <stdio.h>
|
2008-02-22 12:44:35 +01:00
|
|
|
|
2008-02-22 11:22:22 +01:00
|
|
|
class Loggable
|
|
|
|
{
|
|
|
|
|
2008-02-22 21:20:44 +01:00
|
|
|
static FILE *_fp;
|
2008-02-22 12:44:35 +01:00
|
|
|
static int _log_id;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int _id;
|
|
|
|
|
2008-02-22 11:22:22 +01:00
|
|
|
public:
|
|
|
|
|
2008-02-22 21:20:44 +01:00
|
|
|
static bool open ( const char *filename );
|
|
|
|
|
2008-02-22 12:44:35 +01:00
|
|
|
Loggable ( )
|
|
|
|
{
|
|
|
|
_id = ++_log_id;
|
|
|
|
}
|
|
|
|
|
2008-02-22 11:22:22 +01:00
|
|
|
/* log messages for journal */
|
|
|
|
virtual void log_create ( void ) = 0;
|
|
|
|
virtual void log_destroy ( void ) = 0;
|
|
|
|
virtual void log_move ( void ) = 0;
|
|
|
|
virtual void log_change ( void ) = 0;
|
2008-02-22 12:44:35 +01:00
|
|
|
|
|
|
|
void log ( const char *module, const char *action, const char *fmt, ... );
|
|
|
|
|
2008-02-22 11:22:22 +01:00
|
|
|
};
|
2008-02-22 12:44:35 +01:00
|
|
|
|
|
|
|
#ifndef _LOGGABLE_C
|
|
|
|
#define log( act, fmt, args... ) log( __CLASS__, act, fmt, ## args )
|
|
|
|
#endif
|