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
93typedef void (*AtMsgCallBack)(int logmask, int severity, const char* msg_string, int tabs);
94
104typedef void (*AtMsgExtendedCallBack)(int logmask, int severity, const char* msg_string, AtParamValueMap* metadata, void* user_ptr);
105
106AI_API void AiMsgSetLogFileName(const char* filename);
107AI_API void AiMsgSetLogFileFlags(const AtUniverse* universe, int flags);
108AI_API void AiMsgSetConsoleFlags(const AtUniverse* universe, int flags);
109AI_API int AiMsgGetLogFileFlags(const AtUniverse* universe);
110AI_API int AiMsgGetConsoleFlags(const AtUniverse* universe);
111
112AI_API void AiMsgSetMaxWarnings(int max_warnings);
113AI_API AI_DEPRECATED void AiMsgSetCallback(AtMsgCallBack func);
114AI_API AI_DEPRECATED void AiMsgAddCallback(AtMsgCallBack func);
115AI_API AI_DEPRECATED void AiMsgResetCallback();
116AI_API unsigned int AiMsgRegisterCallback(AtMsgExtendedCallBack func, int mask, void* user_ptr);
117AI_API void AiMsgDeregisterCallback(unsigned int callback_id);
118AI_API void AiMsgSetCallbackMask(unsigned int callback_id, int mask);
119AI_API int AiMsgGetCallbackMask(unsigned int callback_id);
120
121#ifdef AI_GPU_COMPILER
122# define AiMsgInfo(format, ...) // do nothing
123# define AiMsgDebug(format, ...) // do nothing
124# define AiMsgWarning(format, ...) // do nothing
125# define AiMsgError(format, ...) // do nothing
126# define AiMsgFatal(format, ...) // do nothing
127#else
128AI_API void AiMsgInfo(const char* format, ...) AI_PRINTF_ARGS(1,2);
129AI_API void AiMsgDebug(const char* format, ...) AI_PRINTF_ARGS(1,2);
130AI_API void AiMsgWarning(const char* format, ...) AI_PRINTF_ARGS(1,2);
131AI_API void AiMsgError(const char* format, ...) AI_PRINTF_ARGS(1,2);
132AI_API void AiMsgFatal(const char* format, ...) AI_PRINTF_ARGS(1,2);
133#endif
134
135AI_API void AiMsgTab(int tabinc);
136
137AI_API size_t AiMsgUtilGetUsedMemory();
138AI_API uint32_t AiMsgUtilGetElapsedTime();
139
140AI_API void AiMsgSystemInfo(const AtUniverse* universe);
141
142/*\}*/
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:210
AI_API void AiMsgWarning(const char *format,...)
Send a warning message to the log.
Definition: ai_msg.cpp:292
void(* AtMsgCallBack)(int logmask, int severity, const char *msg_string, int tabs)
Custom message callback, as passed to AiMsgSetCallback()
Definition: ai_msg.h:93
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:104
AI_API void AiMsgSystemInfo(const AtUniverse *universe)
Output system information to the log.
Definition: ai_msg.cpp:410
AI_API uint32_t AiMsgUtilGetElapsedTime()
Elapsed time since AiBegin()
Definition: ai_msg.cpp:395
AI_API void AiMsgDebug(const char *format,...)
Send a debug message to the log.
Definition: ai_msg.cpp:269
AI_API unsigned int AiMsgRegisterCallback(AtMsgExtendedCallBack func, int mask, void *user_ptr)
Add an additional logging callback function.
Definition: ai_msg.cpp:199
AI_API void AiMsgError(const char *format,...)
Send an error message to the log.
Definition: ai_msg.cpp:322
AI_API int AiMsgGetCallbackMask(unsigned int callback_id)
Returns the mask of a previously registered logging callback function.
Definition: ai_msg.cpp:235
AI_API AI_DEPRECATED void AiMsgResetCallback()
Reset the logging callback function to its default value.
Definition: ai_msg.cpp:182
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:250
AI_API void AiMsgSetCallbackMask(unsigned int callback_id, int mask)
Sets the mask of a previously registered logging callback function.
Definition: ai_msg.cpp:223
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 AI_DEPRECATED void AiMsgSetCallback(AtMsgCallBack func)
Change the logging callback function.
Definition: ai_msg.cpp:152
AI_API void AiMsgFatal(const char *format,...)
Send a fatal error message to the log.
Definition: ai_msg.cpp:353
AI_API AI_DEPRECATED void AiMsgAddCallback(AtMsgCallBack func)
Add an additional logging callback function.
Definition: ai_msg.cpp:168
AI_API void AiMsgTab(int tabinc)
Change the indentation of subsequent log messages.
Definition: ai_msg.cpp:374
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:384
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.

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