Log File Functionsv3LogOpenSyntax#include "log.h" s32 v3LogOpen( v3_LOG * log, ascii * filename, u32 max_level, u32 mode ); DescriptionInitialize the log, setting the filename, max_level, and mode. If V3_LOG_MODE_NUMBER then log any message with an equal or lower level than max_level. If V3_LOG_MODE_BITS then log any message with it's level matching a bit in max_level. Initializing a log with a NULL filename or invalid mode causes failure. Log modes:
Return ValuesV3_PASS on success, or an error code on failure. Errors
Examplev3_LOG log; s32 result; v3MemSet( &log, v3u64u32( sizeof( v3_LOG ) ), 0 ); result = v3LogOpen( &log, "/var/log/cosmlog", 5, V3_LOG_MODE_NUMBER ); if ( result == V3_PASS ) { v3PrintA( "Log file /var/log/cosmlog initialized.\n" ); } else { v3PrintA( "Unable to open /var/log/cosmlog.\n" ); } v3LogSyntax#include "log.h" s32 v3Log( v3_LOG * log, u32 level, u32 echo, const ascii * format, ... ); DescriptionWrite the formatted string to the log. See v3PrintA for format info. The string will be logged only if the level is acceptable to the open log. Level 0 will always be logged. If echo is V3_LOG_ECHO and the level passes then the string will also be printed to the standard output device. Otherwise if level does not pass or echo is V3_LOG_NOECHO nothing will be printed. Return ValuesV3_PASS on success, or an error code on failure. Errors
Examplev3_LOG log; v3MemSet( &log, v3u64u32( sizeof( v3_LOG ) ), 0 ); v3LogOpen( &log, (ascii *) "file.log", 5, V3_LOG_MODE_NUMBER ); /* check for errors */ v3Log( &log, 3, V3_LOG_NOECHO, (ascii *) "This is logged. 3 is less than 5.\n" ); v3Log( &log, 8, V3_LOG_NOECHO, (ascii *) "This is not logged. 8 is greater than 5.\n" ); v3LogClose( &log ); v3LogOpen( &log, (ascii *) "file.log", 0x55, V3_LOG_MODE_BITS ); /* check for errors */ v3Log( &log, 0x03, V3_LOG_NOECHO, (ascii *) "This is logged. ( 0x03 & 0x55 ) != 0.\n" ); v3Log( &log, 0x08, V3_LOG_NOECHO, (ascii *) "This is not logged. ( 0x08 & 0x55 ) == 0.\n" ); v3Log( &log, 0x00, V3_LOG_NOECHO, (ascii *) "This is logged. Level 0 is ALWAYS logged.\n" ); v3LogClose( &log ); v3LogCloseSyntax#include "log.h" s32 v3LogClose( v3_LOG * log ); DescriptionClose the log. Return ValuesV3_PASS on success. ErrorsNone. Examplev3_LOG log; v3MemSet( &log, v3u64u32( sizeof( v3_LOG ) ), 0 ); /* ... */ v3LogClose( &log );
© Copyright Mithral Communications & Design Inc.
1995-2003.
All rights reserved.
Mithral® and Cosm® are trademarks of
Mithral Communications & Design Inc.
|