Katana Plug-in APIs 0.1

FnLoggingSuite.h

00001 // Copyright (c) 2012 The Foundry Visionmongers Ltd. All Rights Reserved.
00002 
00003 #ifndef FnLoggingSuite_H
00004 #define FnLoggingSuite_H
00005 
00006 #include <stdint.h>
00007 
00008 extern "C" {
00009 
00012 enum
00013 {
00014     kFnLoggingSeverityDebug = 10,
00015     kFnLoggingSeverityInfo = 20,
00016     kFnLoggingSeverityWarning = 30,
00017     kFnLoggingSeverityError = 40,
00018     kFnLoggingSeverityCritical = 50,
00019 };
00020 typedef int FnLoggingSeverity;
00021 
00022 typedef void (*FnLogHandler)(const char* message,
00023                              FnLoggingSeverity severity,
00024                              const char* module,
00025                              const char* file,
00026                              int line,
00027                              int64_t timestamp,
00028                              void* userdata);
00029 
00030 typedef void (*FnLogHandlerLegacy)(const char* message,
00031                                    unsigned int severity,
00032                                    const char* module,
00033                                    void* userdata);
00034 
00035 #define FnLoggingHostSuite_version 1
00036 
00037 struct FnLoggingHostSuite_v1
00038 {
00039     void (*logLegacy)(const char* message,
00040                       unsigned int severity,
00041                       const char* module);
00042 
00043     void (*registerHandlerLegacy)(FnLogHandlerLegacy handler,
00044                                   void* userData,
00045                                   unsigned int severityFilter,
00046                                   const char* moduleFilter);
00047     void (*unregisterHandlerLegacy)(FnLogHandlerLegacy handler, void* userData);
00048 
00049     // log a message
00050     void (*log)(const char* message,
00051                 FnLoggingSeverity severity,
00052                 const char* module,
00053                 const char* file,
00054                 int line);
00055 
00056     // Returns an opaque token that can be passed to unregisterHandler, or NULL
00057     // on error.
00058     void* (*registerHandler)(FnLogHandler handler,
00059                              void* context,
00060                              FnLoggingSeverity severityThreshold,
00061                              const char* module);
00062     // Returns true iff a handler was unregistered.
00063     int (*unregisterHandler)(void* handlerToken);
00064 
00065     int (*isSeverityEnabled)(const char* module, FnLoggingSeverity severity);
00066 };
00067 }
00068 #endif  // FnLoggingSuite_H
 All Classes Functions Variables Typedefs Enumerations Enumerator