1 /*
2  * Copyright (c) 2022 Converge
3  * Copyright (c) 2023 Nobleo Technology
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 #include <zephyr/logging/log.h>
8 #include <zephyr/logging/log_output.h>
9 #include <zephyr/logging/log_output_custom.h>
10 
11 static log_format_func_t log_custom_format_func;
12 
log_custom_output_msg_process(const struct log_output * output,struct log_msg * msg,uint32_t flags)13 void log_custom_output_msg_process(const struct log_output *output, struct log_msg *msg,
14 				   uint32_t flags)
15 {
16 	if (log_custom_format_func) {
17 		log_custom_format_func(output, msg, flags);
18 	}
19 }
20 
log_custom_output_msg_set(log_format_func_t format)21 void log_custom_output_msg_set(log_format_func_t format)
22 {
23 	log_custom_format_func = format;
24 }
25 
26 static log_timestamp_format_func_t log_timestamp_format_func;
27 
log_custom_timestamp_print(const struct log_output * output,const log_timestamp_t timestamp,const log_timestamp_printer_t printer)28 int log_custom_timestamp_print(const struct log_output *output, const log_timestamp_t timestamp,
29 			      const log_timestamp_printer_t printer)
30 {
31 	__ASSERT(log_timestamp_format_func != NULL, "custom timestamp format function not set");
32 
33 	if (log_timestamp_format_func) {
34 		return log_timestamp_format_func(output, timestamp, printer);
35 	}
36 
37 	return 0;
38 }
39 
log_custom_timestamp_set(log_timestamp_format_func_t format)40 void log_custom_timestamp_set(log_timestamp_format_func_t format)
41 {
42 	log_timestamp_format_func = format;
43 }
44