Debian Codegraph @

src/log.h

raw symbols SCIP
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3 * Copyright (C) 2020-2024 Linutronix GmbH
4 * Author Kurt Kanzenbach <[email protected]>
5 */
6
7 #ifndef _LOG_H_
8 #define _LOG_H_
9
10 #include <pthread.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13
14 #include "ring_buffer.h"
15
16 /* 1 MiB per traffic class */
17 #define LOG_BUFFER_SIZE (8 * 1024 * 1024)
18
19 enum log_level {
20 LOG_LEVEL_ERROR = 1,
21 LOG_LEVEL_WARNING,
22 LOG_LEVEL_INFO,
23 LOG_LEVEL_DEBUG
24 };
25
26 struct log_thread_context {
27 pthread_t log_task_id;
28 struct ring_buffer *log_ring_buffer;
29 unsigned char *log_data;
30 volatile int stop;
31 FILE *file_handle;
32 };
33
34 struct log_thread_context *log_thread_create(void);
35 void log_thread_stop(struct log_thread_context *thread_context);
36 void log_thread_free(struct log_thread_context *thread_context);
37 void log_thread_wait_for_finish(struct log_thread_context *thread_context);
38
39 int log_init(void);
40 void log_message(enum log_level level, const char *format, ...)
41 __attribute__((__format__(printf, 2, 3)));
42 void log_free(void);
43
44 #endif /* _LOG_H_ */