NVIDIA Iray: Base API Home  Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ilogger.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // Copyright 1986, 2016 NVIDIA Corporation. All rights reserved.
3 //*****************************************************************************
8 //*****************************************************************************
9 
10 #ifndef MI_BASE_ILOGGER_H
11 #define MI_BASE_ILOGGER_H
12 
13 #include <cstdarg>
14 #include <cstdio>
15 
16 #include <mi/base/config.h>
17 #include <mi/base/enums.h>
18 #include <mi/base/iinterface.h>
20 
21 namespace mi {
22 
23 namespace base {
24 
37 class ILogger : public
65  Interface_declare<0x4afbf19a,0x5fb7,0x4422,0xae,0x4b,0x25,0x13,0x06,0x2c,0x30,0x5f>
66 {
67 public:
85  virtual void message(
86  Message_severity level, const char* module_category, const char* message) = 0;
87 
107  inline void printf(
108  Message_severity level, const char* module_category, const char* message, ...)
109 #ifdef MI_COMPILER_GCC
110  __attribute__((format(printf, 4, 5)))
111 #endif
112  {
113  va_list args;
114  va_start( args, message);
115  char buffer[1024];
116 #ifdef MI_COMPILER_MSC
117  vsnprintf_s( &buffer[0], sizeof( buffer), sizeof( buffer)-1, message, args);
118 #else
119  vsnprintf( &buffer[0], sizeof( buffer)-1, message, args);
120 #endif
121  this->message( level, module_category, &buffer[0]);
122  va_end( args);
123  }
124 };
125  // end group mi_base_ilogger
127 
128 } // namespace base
129 
130 } // namespace mi
131 
132 #endif // MI_BASE_ILOGGER_H