Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members

FXEX::FXBinaryLogger Class Reference

A binary log file allows applications to log entries to a file, faster and more compact than a normal log file. More...

#include <FXBinaryLogger.h>

List of all members.

Public Types

enum  {
  CODE_NORMAL = 0x0000,
  CODE_WARNING = 0x0001,
  CODE_ERROR = 0x0002,
  CODE_DEBUG = 0x0003
}
enum  {
  LOG_STARTED = 0x7FFF,
  LOG_ENDED = 0x7FFE,
  LOG_UNKNOWN = 0x7FFD
}

Public Methods

 FXBinaryLogger (const FXString &file="", FXlong size=100000, FXuint opts=0)
void size (const FXlong size)
FXlong size ()
FXbool name (const FXString &file)
FXString name ()
FXbool opened ()
void log (FXshort code, FXshort val)
void log (FXshort val)
void warning (FXshort val)
void error (FXshort val)
void debug (FXshort val)
void unknown ()
virtual ~FXBinaryLogger ()

Static Public Methods

FXBinaryLogger & instance ()

Friends

FXStreamoperator<< (FXStream &store, const FXBinaryLogger &b)
FXStreamoperator>> (FXStream &store, FXBinaryLogger &b)


Detailed Description

A binary log file allows applications to log entries to a file, faster and more compact than a normal log file.

How this differs from a normal log file is that, up to 1000% of the speed of a log file is consumed in the printf style parsing of the input string. By using numbers only, no parsing is necessary. As an added bonus, you dont log many bytes per log entry so the disk I/O time is reduced.

The upshot is that a binary logger can run many times quicker than a text file logger, and that the storage of that information is more compact. The downside is that you need a custom program to read the file (see FXBinaryLogReader).

File format:

Notes: 1. The log file stores the endian-ness of the CPU architecture so that the log file can later be read back on any type of CPU. 2. Log entries are automatically written on file open/close (as debug entries)

It is envisaged that you could use this logger in an embedded application. You would log the values you need, when you identify a condition that needs to be logged. You should create a specific enumerated value, for all possible log cases.

Definition at line 84 of file FXBinaryLogger.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
CODE_NORMAL   normal log code.
CODE_WARNING   warning log code.
CODE_ERROR   error log code.
CODE_DEBUG   debug log code.

Definition at line 86 of file FXBinaryLogger.h.

anonymous enum
 

Enumeration values:
LOG_STARTED   log started.
LOG_ENDED   log ended.
LOG_UNKNOWN   log entry unknown.

Definition at line 93 of file FXBinaryLogger.h.


Constructor & Destructor Documentation

FXEX::FXBinaryLogger::FXBinaryLogger const FXString & file = "",
FXlong size = 100000,
FXuint opts = 0
 

Give me a log file.

virtual FXEX::FXBinaryLogger::~FXBinaryLogger [virtual]
 

done.


Member Function Documentation

FXBinaryLogger& FXEX::FXBinaryLogger::instance [static]
 

Use the current instance.

void FXEX::FXBinaryLogger::size const FXlong size
 

Set the size of the log file - checked on next log entry.

FXlong FXEX::FXBinaryLogger::size [inline]
 

Get the size of the log file.

Definition at line 110 of file FXBinaryLogger.h.

FXbool FXEX::FXBinaryLogger::name const FXString & file
 

Change the location of the log file - change is immediate.

FXString FXEX::FXBinaryLogger::name
 

get the current filename.

FXbool FXEX::FXBinaryLogger::opened
 

indicates whether the log file can/will be written to.

void FXEX::FXBinaryLogger::log FXshort code,
FXshort val
 

log a numeric entry.

void FXEX::FXBinaryLogger::log FXshort val
 

log numeric entries based on generic code.

void FXEX::FXBinaryLogger::warning FXshort val
 

void FXEX::FXBinaryLogger::error FXshort val
 

void FXEX::FXBinaryLogger::debug FXshort val
 

void FXEX::FXBinaryLogger::unknown
 

log an error, using the 'unknown' value.


Friends And Related Function Documentation

FXStream& operator<< FXStream & store,
const FXBinaryLogger & b
[friend]
 

Save to stream.

FXStream& operator>> FXStream & store,
FXBinaryLogger & b
[friend]
 

load from stream.