Main Page   Class Hierarchy   Compound List   Header Files   Compound Members  

bglog.h

This is the verbatim text of the bglog.h include file.
#ifndef __BGLOG_H__
#define __BGLOG_H__

/* $Id: bglog.h,v 1.1 2000/02/18 09:04:17 dpfeifle Exp $ */

#include <stdio.h>
#include <stdarg.h>

static const int MAX_TRACE_LENGTH         = 1024;

// Commonly used log configurations

static const long LT_ALL          = 0xffffffff;
static const long LT_NONE         = 0x00000000;
static const long LT_DEFAULT      = 0xffffffff;

// Log Threshold
static const long LT_CRITICAL     = 0x01000000;
static const long LT_ERROR        = 0x02000000;
static const long LT_ASSERTION    = 0x04000000;
static const long LT_WARNING      = 0x08000000;
static const long LT_INFORMAL     = 0x0f000000;
static const long LT_TRACE        = 0x10000000;
static const long LT_DEBUG        = 0xff000000;

// Log Type
static const long LT_GENERAL      = 0x00000001;
static const long LT_MEMORY       = 0x00000002;
static const long LT_NETWORK      = 0x00000003;
static const long LT_APPLICATION  = 0x00000f01;

class BGLogEvent
{
public:
   BGLogEvent                ( );
   BGLogEvent                ( const char *msg, long lt = LT_TRACE | LT_GENERAL );
  ~BGLogEvent                ( );

void
   setType                   ( long lt ) { logtype=lt; }
long
   type                      ( ) const { return logtype; }
const char*
   msg                       ( ) const { return message; }
   
private:
long
   logtype;
char
   *message;
};

//class BGString;

class BGLogger
{
public:
   BGLogger                  ( long lt = LT_DEFAULT, FILE *fp=stderr );
  ~BGLogger                  ( );

void
   write                     ( BGLogEvent &entry );

void
   setTrace                  ( long lt ) { log_type = lt; }
bool
   doTrace                   ( long lt ) { return (log_type & lt >0) ? 1 : 0; }
void
   setOutput                 ( FILE *fp ) { file_ptr = fp; }

void
   _devnull                  ( const char *format, ... );
void 
   _atrace                   ( const char *format, ... );
void
   _mtrace                   ( const char *format, ... );
void 
   _debug                    ( const char *format, ... );

private:
FILE
   *file_ptr;
long
   log_type;
};

static BGLogger logger;

// We define some useful abbreviations here...

#ifndef SILENT_MODE
   #define atrace       logger._atrace
   #define mtrace       logger._mtrace
#else
   #define atrace       logger._devnull
   #define mtrace       logger._devnull
#endif

#ifdef DEBUG
   #define debug        logger._debug
#else
   #define debug        logger._devnull
#endif

#endif

Generated at Fri Feb 18 10:57:06 2000 for bgclass by doxygen 0.49-991205 written by Dimitri van Heesch, © 1997-1999