simple logging

David Medlock noone at nowhere.com
Tue Apr 4 17:36:23 PDT 2006


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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: logging.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20060404/7738954a/attachment.ksh>


More information about the Digitalmars-d mailing list