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. See v3FileOpen in cosmfile.h for how to specify the path and file name. 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; log = v3MemAlloc( v3u64u32( sizeof( v3_LOG ) ), V3_MEM_NORMAL ); 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; log = v3MemAlloc( v3u64u32( sizeof( v3_LOG ) ), V3_MEM_NORMAL ); /* ... */ v3LogOpen( log, (ascii *) "file.log", 5, V3_LOG_MODE_NUMBER ); 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 ); 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, or an error code on failure. ErrorsExample
© Copyright Mithral Communications & Design, Inc. 1999.
All rights reserved.
Mithral(tm) and Cosm(tm) are trademarks of
Mithral Communications & Design, Inc.
|