ai_msg.h
Go to the documentation of this file.
1// Copyright 2023 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
17class AtUniverse;
18struct AtParamValueMap;
19
27#if !defined(__AI_FILE__)
28#define __AI_FILE__ __FILE__
29#endif
30#if !defined(__AI_LINE__)
31#define __AI_LINE__ __LINE__
32#endif
33#if !defined(__AI_FUNCTION__)
34#define __AI_FUNCTION__ __FUNCTION__
35#endif
36
41#define AI_SEVERITY_INFO 0x00
42#define AI_SEVERITY_WARNING 0x01
43#define AI_SEVERITY_ERROR 0x02
44#define AI_SEVERITY_FATAL 0x03
45/*\}*/
46
51#define AI_LOG_NONE 0x0000
52#define AI_LOG_INFO 0x0001
53#define AI_LOG_WARNINGS 0x0002
54#define AI_LOG_ERRORS 0x0004
55#define AI_LOG_DEBUG 0x0008
56#define AI_LOG_STATS 0x0010
57#define AI_LOG_ASS_PARSE 0x0020
58#define AI_LOG_PLUGINS 0x0040
59#define AI_LOG_PROGRESS 0x0080
60#define AI_LOG_NAN 0x0100
61#define AI_LOG_TIMESTAMP 0x0200
62#define AI_LOG_BACKTRACE 0x0400
63#define AI_LOG_MEMORY 0x0800
64#define AI_LOG_COLOR 0x1000
65#define AI_LOG_STATUS 0x2000
69#define AI_LOG_ALL \
70 ( AI_LOG_INFO | AI_LOG_WARNINGS | AI_LOG_ERRORS | \
71 AI_LOG_DEBUG | AI_LOG_STATS | AI_LOG_PLUGINS | \
72 AI_LOG_PROGRESS | AI_LOG_NAN | AI_LOG_ASS_PARSE | \
73 AI_LOG_TIMESTAMP | AI_LOG_BACKTRACE | AI_LOG_MEMORY | \
74 AI_LOG_COLOR )
75/*\}*/
76
77#ifndef AI_PRINTF_ARGS
78# ifdef __GNUC__
79 // Enable printf-like warnings with gcc by attaching
80 // AI_PRINTF_ARGS to printf-like functions. Eg:
81 //
82 // void foo (const char* fmt, ...) AI_PRINTF_ARGS(1,2);
83 //
84 // The arguments specify the positions of the format string and the the
85 // beginning of the varargs parameter list respectively.
86# define AI_PRINTF_ARGS(fmtarg_pos, vararg_pos) __attribute__ ((format (printf, fmtarg_pos, vararg_pos) ))
87# else
88# define AI_PRINTF_ARGS(fmtarg_pos, vararg_pos)
89# endif
90#endif
91
101typedef void (*AtMsgExtendedCallBack)(int logmask, int severity, const char* msg_string, AtParamValueMap* metadata, void* user_ptr);
102
103AI_API void AiMsgSetLogFileName(const char* filename);
104AI_API void AiMsgSetLogFileFlags(const AtUniverse* universe, int flags);
105AI_API void AiMsgSetConsoleFlags(const AtUniverse* universe, int flags);
106AI_API int AiMsgGetLogFileFlags(const AtUniverse* universe);
107AI_API int AiMsgGetConsoleFlags(const AtUniverse* universe);
108
109AI_API void AiMsgSetMaxWarnings(int max_warnings);
110AI_API unsigned int AiMsgRegisterCallback(AtMsgExtendedCallBack func, int mask, void* user_ptr);
111AI_API void AiMsgDeregisterCallback(unsigned int callback_id);
112AI_API void AiMsgSetCallbackMask(unsigned int callback_id, int mask);
113AI_API int AiMsgGetCallbackMask(unsigned int callback_id);
114
115#ifdef AI_GPU_COMPILER
116# define AiMsgInfo(format, ...) // do nothing
117# define AiMsgDebug(format, ...) // do nothing
118# define AiMsgWarning(format, ...) // do nothing
119# define AiMsgError(format, ...) // do nothing
120# define AiMsgFatal(format, ...) // do nothing
121#else
122AI_API void AiMsgInfo(const char* format, ...) AI_PRINTF_ARGS(1,2);
123AI_API void AiMsgDebug(const char* format, ...) AI_PRINTF_ARGS(1,2);
124AI_API void AiMsgWarning(const char* format, ...) AI_PRINTF_ARGS(1,2);
125AI_API void AiMsgError(const char* format, ...) AI_PRINTF_ARGS(1,2);
126AI_API void AiMsgFatal(const char* format, ...) AI_PRINTF_ARGS(1,2);
127#endif
128
129AI_API void AiMsgTab(int tabinc);
130
131AI_API size_t AiMsgUtilGetUsedMemory();
132AI_API uint32_t AiMsgUtilGetElapsedTime();
133
134AI_API void AiMsgSystemInfo(const AtUniverse* universe);
135
136/*\}*/
DLL export prefix for API functions (necessary for multi-platform development)
AI_API void AiMsgDeregisterCallback(unsigned int callback_id)
Remove a previously registered logging callback function.
Definition: ai_msg.cpp:161
AI_API void AiMsgWarning(const char *format,...)
Send a warning message to the log.
Definition: ai_msg.cpp:243
void(* AtMsgExtendedCallBack)(int logmask, int severity, const char *msg_string, AtParamValueMap *metadata, void *user_ptr)
Custom message callback, as passed to AiMsgRegisterCallback()
Definition: ai_msg.h:101
AI_API void AiMsgSystemInfo(const AtUniverse *universe)
Output system information to the log.
Definition: ai_msg.cpp:361
AI_API uint32_t AiMsgUtilGetElapsedTime()
Elapsed time since AiBegin()
Definition: ai_msg.cpp:346
AI_API void AiMsgDebug(const char *format,...)
Send a debug message to the log.
Definition: ai_msg.cpp:220
AI_API unsigned int AiMsgRegisterCallback(AtMsgExtendedCallBack func, int mask, void *user_ptr)
Add an additional logging callback function.
Definition: ai_msg.cpp:150
AI_API void AiMsgError(const char *format,...)
Send an error message to the log.
Definition: ai_msg.cpp:273
AI_API int AiMsgGetCallbackMask(unsigned int callback_id)
Returns the mask of a previously registered logging callback function.
Definition: ai_msg.cpp:186
AI_API void AiMsgSetConsoleFlags(const AtUniverse *universe, int flags)
Set the mask for what types of messages from the specified universe can be written to stdout.
Definition: ai_msg.cpp:78
AI_API void AiMsgInfo(const char *format,...)
Send an information message to the log.
Definition: ai_msg.cpp:201
AI_API void AiMsgSetCallbackMask(unsigned int callback_id, int mask)
Sets the mask of a previously registered logging callback function.
Definition: ai_msg.cpp:174
AI_API int AiMsgGetLogFileFlags(const AtUniverse *universe)
Get the type of messages that will be written to the log file for a given universe.
Definition: ai_msg.cpp:97
AI_API void AiMsgSetLogFileFlags(const AtUniverse *universe, int flags)
Set the mask for what types of messages from the specified universe can be written to the log file.
Definition: ai_msg.cpp:57
AI_API void AiMsgFatal(const char *format,...)
Send a fatal error message to the log.
Definition: ai_msg.cpp:304
AI_API void AiMsgTab(int tabinc)
Change the indentation of subsequent log messages.
Definition: ai_msg.cpp:325
AI_API void AiMsgSetMaxWarnings(int max_warnings)
Set the maximum number of reported warnings.
Definition: ai_msg.cpp:133
AI_API size_t AiMsgUtilGetUsedMemory()
Memory used by this process in bytes.
Definition: ai_msg.cpp:335
AI_API int AiMsgGetConsoleFlags(const AtUniverse *universe)
Get the type of messages that will be written to the stdout for a given universe.
Definition: ai_msg.cpp:116
AI_API void AiMsgSetLogFileName(const char *filename)
Enable writing messages to the specified log file.
Definition: ai_msg.cpp:30
This represents a universe in Arnold.

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