Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef LOGGER_H
00026 #define LOGGER_H
00027
00088 #ifdef __cplusplus
00089 extern "C" {
00090 #endif
00091
00092 #include <stdio.h>
00093 #include <stdarg.h>
00094
00095 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
00096
00098
00099
00100
00101
00102
00103
00105 #ifdef WIN32
00106 #define DECLSPEC __declspec(dllexport)
00107 #else
00108 #define DECLSPEC
00109 #endif
00110
00111
00112 #ifndef CALLCONVENTION
00113 #ifdef WIN32
00114 #define CALLCONVENTION __cdecl
00115 #else
00116 #define CALLCONVENTION
00117 #endif
00118 #endif
00119
00120
00121
00122
00123 #define LOGGER_MAJOR_VERSION 0
00124 #define LOGGER_MINOR_VERSION 1
00125 #define LOGGER_PATCH_VERSION 0
00126
00128 #endif
00129
00139 typedef struct
00140 {
00141 int major;
00142 int minor;
00143 int patch;
00144 } LoggerVersion;
00145
00146
00159 #define LOGGER_GET_COMPILED_VERSION(X) \
00160 { \
00161 if(NULL != (X)) \
00162 { \
00163 (X)->major = LOGGER_MAJOR_VERSION; \
00164 (X)->minor = LOGGER_MINOR_VERSION; \
00165 (X)->patch = LOGGER_PATCH_VERSION; \
00166 } \
00167 }
00168
00192 extern DECLSPEC void CALLCONVENTION Logger_GetLinkedVersion(LoggerVersion* ver);
00193
00203 extern DECLSPEC int CALLCONVENTION Logger_IsCompiledWithLocking();
00204
00212 typedef struct
00213 {
00214 char* baseName;
00215 size_t baseNameMaxSize;
00217 FILE* fileHandle;
00218 FILE* echoHandle;
00220 unsigned int thresholdPriority;
00221 unsigned int defaultPriority;
00223 int echoOn;
00224 int loggingEnabled;
00225 int autoFlushEnabled;
00227 unsigned int preNewLines;
00228 unsigned int postNewLines;
00230 unsigned int segmentNumber;
00231 unsigned int currentByteCount;
00232 unsigned int minSegmentBytes;
00234 char* segmentFormatString;
00235 size_t segmentFormatStringMaxSize;
00243 void* opaqueLoggerData;
00244
00245 } Logger;
00246
00271 extern DECLSPEC Logger* CALLCONVENTION Logger_Create();
00272
00292 extern DECLSPEC Logger* CALLCONVENTION Logger_CreateWithName(const char* base_name);
00293
00324 extern DECLSPEC Logger* CALLCONVENTION Logger_CreateWithHandle(
00325 FILE* file_handle,
00326 const char* base_name);
00327
00340 extern DECLSPEC void CALLCONVENTION Logger_Free(Logger* logger);
00341
00342
00375 extern DECLSPEC int CALLCONVENTION Logger_SetHandle(
00376 Logger* logger,
00377 FILE* file_handle,
00378 const char* base_name);
00379
00428 extern DECLSPEC int CALLCONVENTION Logger_LogEvent(
00429 Logger* logger,
00430 unsigned int priority,
00431 const char* keyword, const char* subkeyword,
00432 const char* text, ...);
00433
00441 extern DECLSPEC int CALLCONVENTION Logger_LogEventv(
00442 Logger* logger,
00443 unsigned int priority,
00444 const char* keyword, const char* subkeyword,
00445 const char* text, va_list argp);
00446
00463 extern DECLSPEC int CALLCONVENTION Logger_LogEventNoFormat(
00464 Logger* logger,
00465 unsigned int priority,
00466 const char* keyword, const char* subkeyword,
00467 const char* text);
00468
00476 extern DECLSPEC void CALLCONVENTION Logger_Enable(Logger* logger);
00477
00484 extern DECLSPEC void CALLCONVENTION Logger_Disable(Logger* logger);
00485
00494 extern DECLSPEC int CALLCONVENTION Logger_IsEnabled(Logger* logger);
00495
00502 extern DECLSPEC void CALLCONVENTION Logger_Flush(Logger* logger);
00503
00513 extern DECLSPEC void CALLCONVENTION Logger_EnableAutoFlush(Logger* logger);
00514
00524 extern DECLSPEC void CALLCONVENTION Logger_DisableAutoFlush(Logger* logger);
00525
00534 extern DECLSPEC int CALLCONVENTION Logger_IsAutoFlushEnabled(Logger* logger);
00535
00549 extern DECLSPEC void CALLCONVENTION Logger_SetThresholdPriority(Logger* logger, unsigned int thresh_val);
00550
00559 extern DECLSPEC unsigned int CALLCONVENTION Logger_GetThresholdPriority(Logger* logger);
00560
00573 extern DECLSPEC void CALLCONVENTION Logger_SetDefaultPriority(Logger* logger, unsigned int pri_level);
00574
00583 extern DECLSPEC unsigned int CALLCONVENTION Logger_GetDefaultPriority(Logger* logger);
00584
00598 extern DECLSPEC void CALLCONVENTION Logger_SetMinSegmentSize(Logger* logger, unsigned int num_bytes);
00599
00610 extern DECLSPEC unsigned int CALLCONVENTION Logger_GetMinSegmentSize(Logger* logger);
00611
00621 extern DECLSPEC void CALLCONVENTION Logger_EchoOn(Logger* logger);
00622
00630 extern DECLSPEC void CALLCONVENTION Logger_EchoOff(Logger* logger);
00631
00640 extern DECLSPEC int CALLCONVENTION Logger_IsEchoOn(Logger* logger);
00641
00652 extern DECLSPEC void CALLCONVENTION Logger_SetEchoToStdout(Logger* logger);
00653
00663 extern DECLSPEC void CALLCONVENTION Logger_SetEchoToStderr(Logger* logger);
00664
00665
00666
00667
00668
00669
00670
00671
00680 extern DECLSPEC void CALLCONVENTION Logger_SetPreLines(Logger* logger, unsigned int pre_lines);
00681
00690 extern DECLSPEC void CALLCONVENTION Logger_SetPostLines(Logger* logger, unsigned int post_lines);
00691
00702 extern DECLSPEC void CALLCONVENTION Logger_SetNewLines(Logger* logger, unsigned int pre_lines, unsigned int post_lines);
00703
00712 extern DECLSPEC unsigned int CALLCONVENTION Logger_GetPreLines(Logger* logger);
00713
00722 extern DECLSPEC unsigned int CALLCONVENTION Logger_GetPostLines(Logger* logger);
00723
00724
00737 extern DECLSPEC int CALLCONVENTION Logger_WillLog(Logger* logger, unsigned int which_priority);
00738
00739
00773 extern DECLSPEC void CALLCONVENTION Logger_SetSegmentFormatString(Logger* logger, const char* format_string);
00774
00775
00783 extern Logger* g_logger;
00784
00785
00786
00787 #ifdef __cplusplus
00788 }
00789 #endif
00790 #endif
00791