00001 #include "nq_system.h" 00002 #include <assert.h> 00003 #include "PlatformSW.h" 00004 #include "NQDeclarations.h" 00005 #include "NQLogging.h" 00006 00007 #if NQ_NO_LOGGING == 0 00008 00009 const char *gNQLoggingSrcFile = NULL; 00010 int gNQLoggingType = 0; 00011 int gNQLoggingLine= 0; 00012 00013 00014 void exampleNQLoggingSetParameters(int aType, const char *aSrcFile, const int aLine) 00015 { 00016 gNQLoggingSrcFile = aSrcFile; 00017 gNQLoggingType = aType; 00018 gNQLoggingLine = aLine; 00019 } 00020 00021 void exampleNQLoggingHandler(const char *aFormatString,...) 00022 { 00023 bool badLoggingType=true; 00024 00025 FILE *filepointer = stderr; 00026 bool bCloseFileAtExit = false; 00027 00028 switch (gNQLoggingType) 00029 { 00030 case NQ_DBG_TYP: 00031 fprintf(filepointer, "[NQ DEBUG %s:%d]: ", gNQLoggingSrcFile, gNQLoggingLine); 00032 break; 00033 00034 default: 00035 assert( badLoggingType == false ); 00036 break; 00037 } 00038 00039 va_list args; 00040 00041 va_start( args, aFormatString); // Write Data 00042 vfprintf( filepointer , aFormatString, args); 00043 va_end( args ); 00044 00045 if (bCloseFileAtExit == true) 00046 { 00047 fclose(filepointer); 00048 } 00049 } 00050 00051 #endif