www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - simple logging

Yet another source post of mine, those who find it useful let me know 
how I can improve it.

Simple lightweight(150 lines) logging facility, direct and works fairly 
well for me.

Main function is

void  Log( char[] id, ... )

which takes the name of the logfile, and the rest is formatted just like 
std.string.format.

There are a few shortcuts predefined:
void LogInfo( ... )
void LogWarning( ... )
void LogFatal( ... )

There is also:
DebugLogs()

which simply spews info about each log to stdout.

You can set the logging directory, buffer size, and Flush all logs with:
void  SetLoggingDir( char[] dir )
void  SetLogBufferSize( uint sz )
void  SetLogBufferSize( char[] id, uint sz )

If you want to keep log file to a minimum use:
void  SetMaxLogSize( uint sz )

There is probably a lot to make better, but I wrote this a while back, 
and it hasn't given me any problems.

The main feature maybe needed is to null out the Logging if not in debug 
mode.

Untested outside Win32.
Public Domain.
-DavidM
Apr 04 2006