ai_msg.h
Go to the documentation of this file.
1 // Copyright 2020 Autodesk, Inc. All rights reserved.
2 //
3 // Use of this software is subject to the terms of the Autodesk license
4 // agreement provided at the time of installation or download, or which
5 // otherwise accompanies this software in either electronic or hard copy form.
6 
12 #pragma once
13 #include "ai_api.h"
14 #include <stdint.h> // uint32_t etc
15 #include <stddef.h>
16 
24 #if !defined(__AI_FILE__)
25 #define __AI_FILE__ __FILE__
26 #endif
27 #if !defined(__AI_LINE__)
28 #define __AI_LINE__ __LINE__
29 #endif
30 #if !defined(__AI_FUNCTION__)
31 #define __AI_FUNCTION__ __FUNCTION__
32 #endif
33 
38 #define AI_SEVERITY_INFO 0x00
39 #define AI_SEVERITY_WARNING 0x01
40 #define AI_SEVERITY_ERROR 0x02
41 #define AI_SEVERITY_FATAL 0x03
42 /*\}*/
43 
48 #define AI_LOG_NONE 0x0000
49 #define AI_LOG_INFO 0x0001
50 #define AI_LOG_WARNINGS 0x0002
51 #define AI_LOG_ERRORS 0x0004
52 #define AI_LOG_DEBUG 0x0008
53 #define AI_LOG_STATS 0x0010
54 #define AI_LOG_ASS_PARSE 0x0020
55 #define AI_LOG_PLUGINS 0x0040
56 #define AI_LOG_PROGRESS 0x0080
57 #define AI_LOG_NAN 0x0100
58 #define AI_LOG_TIMESTAMP 0x0200
59 #define AI_LOG_BACKTRACE 0x0400
60 #define AI_LOG_MEMORY 0x0800
61 #define AI_LOG_COLOR 0x1000
63 #define AI_LOG_ALL \
64  ( AI_LOG_INFO | AI_LOG_WARNINGS | AI_LOG_ERRORS | \
65  AI_LOG_DEBUG | AI_LOG_STATS | AI_LOG_PLUGINS | \
66  AI_LOG_PROGRESS | AI_LOG_NAN | AI_LOG_ASS_PARSE | \
67  AI_LOG_TIMESTAMP | AI_LOG_BACKTRACE | AI_LOG_MEMORY | \
68  AI_LOG_COLOR )
69 /*\}*/
70 
71 #ifndef AI_PRINTF_ARGS
72 # ifdef __GNUC__
73  // Enable printf-like warnings with gcc by attaching
74  // AI_PRINTF_ARGS to printf-like functions. Eg:
75  //
76  // void foo (const char* fmt, ...) AI_PRINTF_ARGS(1,2);
77  //
78  // The arguments specify the positions of the format string and the the
79  // beginning of the varargs parameter list respectively.
80 # define AI_PRINTF_ARGS(fmtarg_pos, vararg_pos) __attribute__ ((format (printf, fmtarg_pos, vararg_pos) ))
81 # else
82 # define AI_PRINTF_ARGS(fmtarg_pos, vararg_pos)
83 # endif
84 #endif
85 
87 typedef void (*AtMsgCallBack)(int logmask, int severity, const char* msg_string, int tabs);
88 
89 
91 struct AtParamValueMap;
92 typedef void (*AtMsgExtendedCallBack)(int logmask, int severity, const char* msg_string, AtParamValueMap* metadata, void* user_ptr);
93 
94 AI_API void AiMsgSetLogFileName(const char* filename);
95 AI_API void AiMsgSetLogFileFlags(int flags);
96 AI_API void AiMsgSetConsoleFlags(int flags);
97 AI_API int AiMsgGetLogFileFlags();
98 AI_API int AiMsgGetConsoleFlags();
99 AI_API void AiMsgSetMaxWarnings(int max_warnings);
100 AI_API void AiMsgSetCallback(AtMsgCallBack func);
101 AI_API void AiMsgAddCallback(AtMsgCallBack func);
102 AI_API void AiMsgResetCallback();
103 AI_API unsigned int AiMsgRegisterCallback(AtMsgExtendedCallBack func, int mask, void* user_ptr);
104 AI_API void AiMsgDeregisterCallback(unsigned int callback_id);
105 AI_API void AiMsgSetCallbackMask(unsigned int callback_id, int mask);
106 AI_API int AiMsgGetCallbackMask(unsigned int callback_id);
107 
108 #ifdef AI_GPU_COMPILER
109 # define AiMsgInfo(format, ...) // do nothing
110 # define AiMsgDebug(format, ...) // do nothing
111 # define AiMsgWarning(format, ...) // do nothing
112 # define AiMsgError(format, ...) // do nothing
113 # define AiMsgFatal(format, ...) // do nothing
114 #else
115 AI_API void AiMsgInfo(const char* format, ...) AI_PRINTF_ARGS(1,2);
116 AI_API void AiMsgDebug(const char* format, ...) AI_PRINTF_ARGS(1,2);
117 AI_API void AiMsgWarning(const char* format, ...) AI_PRINTF_ARGS(1,2);
118 AI_API void AiMsgError(const char* format, ...) AI_PRINTF_ARGS(1,2);
119 AI_API void AiMsgFatal(const char* format, ...) AI_PRINTF_ARGS(1,2);
120 #endif
121 
122 AI_API void AiMsgTab(int tabinc);
123 
124 AI_API size_t AiMsgUtilGetUsedMemory();
125 AI_API uint32_t AiMsgUtilGetElapsedTime();
126 
127 /*\}*/
AI_API void AiMsgDebug(const char *format,...)
Send a debug message to the log.
Definition: ai_msg.cpp:225
AI_API size_t AiMsgUtilGetUsedMemory()
Memory used by this process in bytes.
Definition: ai_msg.cpp:330
AI_API int AiMsgGetConsoleFlags()
Get the type of messages that will be written to the stdout.
Definition: ai_msg.cpp:89
AI_API void AiMsgSetCallback(AtMsgCallBack func)
Change the logging callback function.
Definition: ai_msg.cpp:119
AI_API void AiMsgSetConsoleFlags(int flags)
Describe the type of messages that will be sent to stdout.
Definition: ai_msg.cpp:63
void(* AtMsgCallBack)(int logmask, int severity, const char *msg_string, int tabs)
Custom message callback, as passed to AiMsgSetCallback()
Definition: ai_msg.h:87
AI_API unsigned int AiMsgRegisterCallback(AtMsgExtendedCallBack func, int mask, void *user_ptr)
Add an additional logging callback function.
Definition: ai_msg.cpp:159
AI_API void AiMsgResetCallback()
Reset the logging callback function to its default value.
Definition: ai_msg.cpp:143
AI_API int AiMsgGetCallbackMask(unsigned int callback_id)
Returns the mask of a previously registered logging callback function.
Definition: ai_msg.cpp:193
DLL export prefix for API functions (necessary for multi-platform development)
AI_API void AiMsgAddCallback(AtMsgCallBack func)
Add an additional logging callback function.
Definition: ai_msg.cpp:132
AI_API void AiMsgSetLogFileName(const char *filename)
Enable writing messages to the specified log file.
Definition: ai_msg.cpp:28
AI_API void AiMsgFatal(const char *format,...)
Send a fatal error message to the log.
Definition: ai_msg.cpp:302
AI_API void AiMsgSetLogFileFlags(int flags)
Describe the type of messages that will be written to the log file.
Definition: ai_msg.cpp:48
AI_API void AiMsgSetMaxWarnings(int max_warnings)
Set the maximum number of reported warnings.
Definition: ai_msg.cpp:103
AI_API void AiMsgWarning(const char *format,...)
Send a warning message to the log.
Definition: ai_msg.cpp:246
AI_API void AiMsgSetCallbackMask(unsigned int callback_id, int mask)
Sets the mask of a previously registered logging callback function.
Definition: ai_msg.cpp:181
AI_API int AiMsgGetLogFileFlags()
Get the type of messages that will be written to the log file.
Definition: ai_msg.cpp:76
AI_API uint32_t AiMsgUtilGetElapsedTime()
Elapsed time since AiBegin()
Definition: ai_msg.cpp:340
AI_API void AiMsgInfo(const char *format,...)
Send an information message to the log.
Definition: ai_msg.cpp:208
AI_API void AiMsgDeregisterCallback(unsigned int callback_id)
Remove a previously registered logging callback function.
Definition: ai_msg.cpp:169
AI_API void AiMsgError(const char *format,...)
Send an error message to the log.
Definition: ai_msg.cpp:274
AI_API void AiMsgTab(int tabinc)
Change the indentation of subsequent log messages.
Definition: ai_msg.cpp:320

© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com