# Callback and Hook LogaxLogger supports callback (or hook), the callbacks are invoked when a new log is sent. The callback can be used to create a custom output format or used to changed out the log is processed (e.g. blink bulb on andruino e.t.c). The output stream can be completely disabled by defining the macro `LOGAX_NO_OUTPUT_STREAM` or setting the option to QUIET using the function `logax_set_quiet`, in this case if callbacks are registered they will be invoked with the log event. The callback function signature is ```c typedef void (*logax_callback)(const char *date, const char *time, const int level, const char *file, const size_t line_number, const char *function_name, const char *fmt, ...); ``` The example below shows how to register a callback which is invoked when there is a new log ```c #include void on_new_log_callback(const char *date, const char *time, const int level, const char *file, const size_t line_number, const char *function_name, const char *fmt, ...) { va_list args; printf(""); printf("\n %s", date); printf("\n ", time); printf("\n %s", GET_LEVEL_STRING(level)); printf("\n %s", file); printf("\n %d", line_number); printf("\n %s", function_name); printf("\n "); va_start(args, fmt);vfprintf(stdout, fmt, args);va_end(args); printf("\n\n"); } int main(int argc, char **argv) { LogaxLogger logax_logger; logax_init_logger(&logax_logger); logax_set_quiet(&logax_logger, 1); logax_logger_add_callback(&logax_logger, on_new_log_callback); logax_logger_trace(&logax_logger, "%s", "Logging the test for TRACE"); logax_logger_debug(&logax_logger, "%s", "Logging the test for DEBUG"); logax_logger_info(&logax_logger, "%s", "Logging the test for INFO"); logax_logger_warn(&logax_logger, "%s", "Logging the test for WARN"); logax_logger_error(&logax_logger, "%s", "Logging the test for ERROR"); logax_logger_fatal(&logax_logger, "%s", "Logging the test for FATAL"); } ``` This gives the following outputs the in XML format as defined in the `on_new_log_callback` function: ```xml 2021-11-21 TRACE C:\Users\azeez\Documents\OPEN_SOURCE\EXOTIC_LIBRARIES\liblogax\test\crash_test.c 25 main Logging the test for TRACE 2021-11-21 DEBUG C:\Users\azeez\Documents\OPEN_SOURCE\EXOTIC_LIBRARIES\liblogax\test\crash_test.c 26 main Logging the test for DEBUG ... ```