oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
include
ove
log.h
Go to the documentation of this file.
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
29
#ifndef OVE_LOG_H
30
#define OVE_LOG_H
31
32
#include "
ove/console.h
"
33
#include "ove_config.h"
34
#include <stdio.h>
35
36
#ifdef __cplusplus
37
extern
"C"
{
38
#endif
39
47
#define OVE_LOG_LEVEL_ERR 0
49
#define OVE_LOG_LEVEL_WRN 1
51
#define OVE_LOG_LEVEL_INF 2
53
#define OVE_LOG_LEVEL_DBG 3
62
#ifndef OVE_LOG_LEVEL
63
#define OVE_LOG_LEVEL OVE_LOG_LEVEL_INF
64
#endif
65
67
#ifdef CONFIG_OVE_NET_HTTPD
68
void
ove_httpd_log_append
(
const
char
*line);
69
#define _OVE_LOG_HTTPD_HOOK(buf) ove_httpd_log_append(buf)
70
#else
71
#define _OVE_LOG_HTTPD_HOOK(buf) ((void)0)
72
#endif
73
74
/* Sim log broadcast is now handled by sim_console.c's ove_console_write,
75
* so no separate hook is needed in the log macro. */
76
#define _OVE_LOG_SIM_HOOK(buf, len) ((void)0)
77
78
#define _OVE_LOG_OUTPUT(prefix, fmt, ...) \
79
do { \
80
char _ove_log_buf[256]; \
81
int _ove_log_len = \
82
snprintf(_ove_log_buf, sizeof(_ove_log_buf), prefix fmt, ##__VA_ARGS__); \
83
if (_ove_log_len > 0) { \
84
_ove_log_buf[_ove_log_len] = '\n'; \
85
_ove_log_buf[_ove_log_len + 1] = '\0'; \
86
ove_console_write(_ove_log_buf, (unsigned int)(_ove_log_len + 1)); \
87
_ove_log_buf[_ove_log_len] = '\0'; \
88
_OVE_LOG_HTTPD_HOOK(_ove_log_buf); \
89
_OVE_LOG_SIM_HOOK(_ove_log_buf, (unsigned int)_ove_log_len); \
90
} \
91
} while (0)
103
#if OVE_LOG_LEVEL >= OVE_LOG_LEVEL_ERR
104
#define OVE_LOG_ERR(fmt, ...) _OVE_LOG_OUTPUT("[E] ", fmt, ##__VA_ARGS__)
105
#else
106
#define OVE_LOG_ERR(fmt, ...) \
107
do { \
108
} while (0)
109
#endif
110
120
#if OVE_LOG_LEVEL >= OVE_LOG_LEVEL_WRN
121
#define OVE_LOG_WRN(fmt, ...) _OVE_LOG_OUTPUT("[W] ", fmt, ##__VA_ARGS__)
122
#else
123
#define OVE_LOG_WRN(fmt, ...) \
124
do { \
125
} while (0)
126
#endif
127
137
#if OVE_LOG_LEVEL >= OVE_LOG_LEVEL_INF
138
#define OVE_LOG_INF(fmt, ...) _OVE_LOG_OUTPUT("[I] ", fmt, ##__VA_ARGS__)
139
#else
140
#define OVE_LOG_INF(fmt, ...) \
141
do { \
142
} while (0)
143
#endif
144
154
#if OVE_LOG_LEVEL >= OVE_LOG_LEVEL_DBG
155
#define OVE_LOG_DBG(fmt, ...) _OVE_LOG_OUTPUT("[D] ", fmt, ##__VA_ARGS__)
156
#else
157
#define OVE_LOG_DBG(fmt, ...) \
158
do { \
159
} while (0)
160
#endif
161
171
#define _OVE_LOG_RAW(fmt, ...) \
172
do { \
173
char _ove_log_buf[256]; \
174
int _ove_log_len = \
175
snprintf(_ove_log_buf, sizeof(_ove_log_buf), fmt, ##__VA_ARGS__); \
176
if (_ove_log_len > 0) { \
177
ove_console_write(_ove_log_buf, (unsigned int)_ove_log_len); \
178
} \
179
} while (0)
180
195
#define OVE_LOG(fmt, ...) _OVE_LOG_RAW(fmt, ##__VA_ARGS__)
196
197
#ifdef __cplusplus
198
}
199
#endif
200
/* end of ove_log group */
202
203
#endif
/* OVE_LOG_H */
console.h
ove_httpd_log_append
void ove_httpd_log_append(const char *line)
Feed a log line into the httpd log ring buffer.
Generated by
1.9.8