Introduce new logging API, fixes #858
PiperOrigin-RevId: 930744288 Change-Id: I6ec1203b55c031390f3eef23192e2337508ce886
This commit is contained in:
committed by
Copybara-Service
parent
a2abaf7aef
commit
58f6d52491
+22
-3
@@ -41,12 +41,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// user error and memory handlers
|
||||
MJAPI extern void (*mju_user_error)(const char*);
|
||||
MJAPI extern void (*mju_user_warning)(const char*);
|
||||
// user memory handlers
|
||||
MJAPI extern void* (*mju_user_malloc)(size_t);
|
||||
MJAPI extern void (*mju_user_free)(void*);
|
||||
|
||||
// legacy error/warning handlers (deprecated: prefer mju_setLogHandler)
|
||||
MJAPI extern void (*mju_user_error)(const char*);
|
||||
MJAPI extern void (*mju_user_warning)(const char*);
|
||||
|
||||
|
||||
// callbacks extending computation pipeline
|
||||
MJAPI extern mjfGeneric mjcb_passive;
|
||||
@@ -71,6 +73,7 @@ MJAPI extern const char* mjLABELSTRING[mjNLABEL];
|
||||
MJAPI extern const char* mjFRAMESTRING[mjNFRAME];
|
||||
MJAPI extern const char* mjVISSTRING[mjNVISFLAG][3];
|
||||
MJAPI extern const char* mjRNDSTRING[mjNRNDFLAG][3];
|
||||
MJAPI extern const char* mjTOPICSTRING[mjNTOPIC];
|
||||
|
||||
|
||||
//---------------------------------- Virtual file system -------------------------------------------
|
||||
@@ -978,6 +981,22 @@ MJAPI void mju_warning(const char* msg, ...) mjPRINTFLIKE(1, 2);
|
||||
// Clear user error and memory handlers.
|
||||
MJAPI void mju_clearHandlers(void);
|
||||
|
||||
// Set the active log handler; return the previous handler.
|
||||
// If handler is NULL, restore the default handler.
|
||||
MJAPI mjfLogHandler mju_setLogHandler(mjfLogHandler handler);
|
||||
|
||||
// Get default handler configuration.
|
||||
MJAPI mjLogConfig mju_getLogConfig(void);
|
||||
|
||||
// Set default handler configuration.
|
||||
MJAPI void mju_setLogConfig(mjLogConfig config);
|
||||
|
||||
// Log an info message with optional topic filtering.
|
||||
MJAPI void mju_info(int topic, const char* msg, ...) mjPRINTFLIKE(2, 3);
|
||||
|
||||
// Dispatch a structured log message to the active handler.
|
||||
MJAPI void mju_message(const mjLogMessage* msg);
|
||||
|
||||
// Allocate memory; byte-align on 64; pad size to multiple of 64.
|
||||
MJAPI void* mju_malloc(size_t size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user