Anjay Lite
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1/*
2 * Copyright 2023-2026 AVSystem <avsystem@avsystem.com>
3 * AVSystem Anjay Lite LwM2M SDK
4 * All rights reserved.
5 *
6 * Licensed under AVSystem Anjay Lite LwM2M Client SDK - Non-Commercial License.
7 * See the attached LICENSE file for details.
8 */
9
10#include <anj/init.h>
11
20#ifndef ANJ_LOG_LOG_H
21# define ANJ_LOG_LOG_H
22
23# include <stdio.h>
24
25# ifdef __cplusplus
26extern "C" {
27# endif
28
29# include <anj/compat/log_impl_decls.h> // IWYU pragma: export
30# include <anj/utils.h>
31
33# define ANJ_INTERNAL_INCLUDE_LOG_FILTERING_UTILS
34# include <anj_internal/log/log_filtering_utils.h>
35# undef ANJ_INTERNAL_INCLUDE_LOG_FILTERING_UTILS
46# define ANJ_LOG_PRINTF_ARG_CHECK(...) ((void) sizeof(printf(__VA_ARGS__)))
47
52# define ANJ_LOG_ENFORCE_FORMAT_INLINE_LITERAL(...) "" __VA_ARGS__
53
62# define ANJ_LOG_COMPILE_TIME_CHECK(...) \
63 ANJ_LOG_PRINTF_ARG_CHECK( \
64 ANJ_LOG_ENFORCE_FORMAT_INLINE_LITERAL(__VA_ARGS__))
65
66# ifdef _ANJ_LOG_ENABLED
67
68# ifdef ANJ_LOG_FULL
69# define ANJ_LOG_HANDLER_IMPL_MACRO(Module, LogLevel, ...) \
70 anj_log_handler_impl_full(ANJ_LOG_LEVEL_##LogLevel, \
71 ANJ_QUOTE_MACRO(Module), __FILE__, \
72 __LINE__, __VA_ARGS__)
73# endif // ANJ_LOG_FULL
74# ifdef ANJ_LOG_MICRO
75# ifndef ANJ_LOG_SOURCE_FILE_ID
76# error "ANJ_LOG_SOURCE_FILE_ID is not defined."
77# endif // ANJ_LOG_SOURCE_FILE_ID
78
79# define ANJ_LOG_HANDLER_IMPL_MACRO(Module, LogLevel, ...) \
80 anj_log_handler_impl_micro(ANJ_LOG_LEVEL_##LogLevel, \
81 ANJ_LOG_SOURCE_FILE_ID, __LINE__, \
82 __VA_ARGS__)
83
84# endif // ANJ_LOG_MICRO
85
86# ifdef ANJ_LOG_ALT_IMPL_HEADER
87# include ANJ_LOG_ALT_IMPL_HEADER
88# endif // ANJ_LOG_ALT_IMPL_HEADER
89
90# ifdef ANJ_LOG_FILTERING_CONFIG_HEADER
91# include ANJ_LOG_FILTERING_CONFIG_HEADER
92# endif // ANJ_LOG_FILTERING_CONFIG_HEADER
93
94# ifndef ANJ_LOG_LEVEL_DEFAULT
95# define ANJ_LOG_LEVEL_DEFAULT L_INFO
96# endif // ANJ_LOG_LEVEL_DEFAULT
97
98# define ANJ_LOG_IF_ALLOWED_LOOKUP_ANJ_LOG_YES(Module, LogLevel, ...) \
99 ANJ_LOG_HANDLER_IMPL_MACRO(Module, LogLevel, __VA_ARGS__)
100# define ANJ_LOG_IF_ALLOWED_LOOKUP_ANJ_LOG_NO(Module, LogLevel, ...) \
101 ((void) 0)
102
103# define ANJ_LOG_IF_ALLOWED(Module, LogLevel, ...) \
104 ANJ_CONCAT(ANJ_LOG_IF_ALLOWED_LOOKUP_, \
105 _ANJ_LOG_EMIT_CALL(LogLevel, \
106 _ANJ_LOG_MODULE_LEVEL(Module))) \
107 (Module, LogLevel, __VA_ARGS__)
108# else // _ANJ_LOG_ENABLED
109# define ANJ_LOG_IF_ALLOWED(Module, LogLevel, ...) ((void) 0)
110# endif // _ANJ_LOG_ENABLED
131# define anj_log(Module, LogLevel, ...) \
132 ((void) (ANJ_LOG_IF_ALLOWED(Module, LogLevel, __VA_ARGS__), \
133 ANJ_LOG_COMPILE_TIME_CHECK(__VA_ARGS__)))
134
136# ifdef ANJ_LOG_STRIP_CONSTANTS
137# define ANJ_LOG_DISPOSABLE_IMPL(Arg) " "
138# else // ANJ_LOG_STRIP_CONSTANTS
139# define ANJ_LOG_DISPOSABLE_IMPL(Arg) Arg
140# endif // ANJ_LOG_STRIP_CONSTANTS
156# define ANJ_LOG_DISPOSABLE(Arg) ANJ_LOG_DISPOSABLE_IMPL(Arg)
157
158# ifdef __cplusplus
159}
160# endif
161
162#endif // ANJ_LOG_LOG_H
Global configuration validation header for Anjay Lite.
Platform hooks for log output.
Public utility helpers used throughout Anjay Lite.