oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
include
ove
log.h
1
/*
2
* Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3
*
4
* SPDX-License-Identifier: GPL-3.0-or-later
5
*
6
* This file is part of oveRTOS.
7
*/
8
28
#ifndef OVE_LOG_H
29
#define OVE_LOG_H
30
31
#include "ove/console.h"
32
#include "ove_config.h"
33
#include <stdio.h>
34
35
#ifdef __cplusplus
36
extern
"C"
{
37
#endif
38
46
#define OVE_LOG_LEVEL_ERR 0
48
#define OVE_LOG_LEVEL_WRN 1
50
#define OVE_LOG_LEVEL_INF 2
52
#define OVE_LOG_LEVEL_DBG 3
61
#ifndef OVE_LOG_LEVEL
62
#define OVE_LOG_LEVEL OVE_LOG_LEVEL_INF
63
#endif
64
66
#ifdef CONFIG_OVE_NET_HTTPD
67
void
ove_httpd_log_append(
const
char
*line);
68
#define _OVE_LOG_HTTPD_HOOK(buf) ove_httpd_log_append(buf)
69
#else
70
#define _OVE_LOG_HTTPD_HOOK(buf) ((void)0)
71
#endif
72
73
#define _OVE_LOG_OUTPUT(prefix, fmt, ...) \
74
do { \
75
char _ove_log_buf[256]; \
76
int _ove_log_len = snprintf(_ove_log_buf, \
77
sizeof(_ove_log_buf), prefix fmt, ##__VA_ARGS__); \
78
if (_ove_log_len > 0) { \
79
_ove_log_buf[_ove_log_len] = '\n'; \
80
_ove_log_buf[_ove_log_len + 1] = '\0'; \
81
ove_console_write(_ove_log_buf, \
82
(unsigned int)(_ove_log_len + 1)); \
83
_ove_log_buf[_ove_log_len] = '\0'; \
84
_OVE_LOG_HTTPD_HOOK(_ove_log_buf); \
85
} \
86
} while (0)
98
#if OVE_LOG_LEVEL >= OVE_LOG_LEVEL_ERR
99
#define OVE_LOG_ERR(fmt, ...) _OVE_LOG_OUTPUT("[E] ", fmt, ##__VA_ARGS__)
100
#else
101
#define OVE_LOG_ERR(fmt, ...) do {} while (0)
102
#endif
103
113
#if OVE_LOG_LEVEL >= OVE_LOG_LEVEL_WRN
114
#define OVE_LOG_WRN(fmt, ...) _OVE_LOG_OUTPUT("[W] ", fmt, ##__VA_ARGS__)
115
#else
116
#define OVE_LOG_WRN(fmt, ...) do {} while (0)
117
#endif
118
128
#if OVE_LOG_LEVEL >= OVE_LOG_LEVEL_INF
129
#define OVE_LOG_INF(fmt, ...) _OVE_LOG_OUTPUT("[I] ", fmt, ##__VA_ARGS__)
130
#else
131
#define OVE_LOG_INF(fmt, ...) do {} while (0)
132
#endif
133
143
#if OVE_LOG_LEVEL >= OVE_LOG_LEVEL_DBG
144
#define OVE_LOG_DBG(fmt, ...) _OVE_LOG_OUTPUT("[D] ", fmt, ##__VA_ARGS__)
145
#else
146
#define OVE_LOG_DBG(fmt, ...) do {} while (0)
147
#endif
148
158
#define _OVE_LOG_RAW(fmt, ...) \
159
do { \
160
char _ove_log_buf[256]; \
161
int _ove_log_len = snprintf(_ove_log_buf, \
162
sizeof(_ove_log_buf), fmt, ##__VA_ARGS__); \
163
if (_ove_log_len > 0) { \
164
ove_console_write(_ove_log_buf, \
165
(unsigned int)_ove_log_len); \
166
} \
167
} while (0)
168
183
#define OVE_LOG(fmt, ...) _OVE_LOG_RAW(fmt, ##__VA_ARGS__)
184
185
#ifdef __cplusplus
186
}
187
#endif
188
/* end of ove_log group */
190
191
#endif
/* OVE_LOG_H */
Generated by
1.9.8