![]() |
|
Uniot Core
|
| 0.8.1 |
Logging system for Uniot devices. More...
Macros | |
| #define | __FUNC_NAME__ __FUNCTION__ |
| Cross-platform function name macro. | |
| #define | UNIOT_LOG_LEVEL_ERROR 0 |
| Log level definitions. | |
| #define | UNIOT_LOG_LEVEL_WARN 1 |
| #define | UNIOT_LOG_LEVEL_INFO 2 |
| #define | UNIOT_LOG_LEVEL_DEBUG 3 |
| #define | UNIOT_LOG_LEVEL_TRACE 4 |
| #define | UNIOT_LOG_STREAM Serial |
| Default log level. | |
| #define | UNIOT_LOG_BAUD_RATE 115200 |
| Default baud rate for serial logging. | |
| #define | UNIOT_LOG_BUF_SIZE 256 |
| Maximum size of the logging buffer. | |
| #define | UNIOT_LOG_SET_READY() |
| Initialize the logging system. | |
| #define | UNIOT_LOG_PRINT(...) |
| Print to the logging stream. | |
| #define | UNIOT_LOG(log_type, log_fmt, log_arg...) |
| Core logging macro. | |
| #define | UNIOT_LOG_IF(log_type, log_cond, log_fmt, log_arg...) |
| Conditional logging macro. | |
| #define | UNIOT_LOG_ERROR(...) |
| Log an ERROR level message Used for critical errors that may prevent normal operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_ERROR. | |
| #define | UNIOT_LOG_ERROR_IF(log_cond, log...) |
| Conditionally log an ERROR level message Used for critical errors that may prevent normal operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_ERROR. | |
| #define | UNIOT_LOG_WARN(...) |
| Log an WARN level message Used for warnings about potentially problematic situations. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_WARN. | |
| #define | UNIOT_LOG_WARN_IF(log_cond, log...) |
| Conditionally log an WARN level message Used for warnings about potentially problematic situations. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_WARN. | |
| #define | UNIOT_LOG_INFO(...) |
| Log an INFO level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_INFO. | |
| #define | UNIOT_LOG_INFO_IF(log_cond, log...) |
| Conditionally log an INFO level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_INFO. | |
| #define | UNIOT_LOG_DEBUG(...) |
| Log an DEBUG level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_DEBUG. | |
| #define | UNIOT_LOG_DEBUG_IF(log_cond, log...) |
| Conditionally log an DEBUG level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_DEBUG. | |
| #define | UNIOT_LOG_TRACE(...) |
| Log an TRACE level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_TRACE. | |
| #define | UNIOT_LOG_TRACE_IF(log_cond, log...) |
| Conditionally log an TRACE level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_TRACE. | |
Logging system for Uniot devices.
This file provides a customizable logging system for Uniot IoT devices. It defines macros for different log levels and provides a consistent logging interface that can be conditionally compiled based on settings.
The logger outputs messages with timestamps, file info, and function names to help with debugging and monitoring device operations.
| #define __FUNC_NAME__ __FUNCTION__ |
Cross-platform function name macro.
Defines a cross-compiler compatible way to get the current function name Works with GCC, Clang, and other compilers
| #define UNIOT_LOG | ( | log_type, | |
| log_fmt, | |||
| log_arg... ) |
Core logging macro.
Formats and outputs a log message with:
| log_type | Type/level of the log message (ERROR, WARN, etc.) |
| log_fmt | Format string for the message |
| log_arg | Variable arguments for format string |
| #define UNIOT_LOG_BAUD_RATE 115200 |
Default baud rate for serial logging.
Sets the communication speed for the logging serial port. Can be overridden by defining UNIOT_LOG_BAUD_RATE before including this file.
| #define UNIOT_LOG_BUF_SIZE 256 |
Maximum size of the logging buffer.
Defines the maximum size of a single log message. Messages longer than this will be truncated with "[...]" indicator.
| #define UNIOT_LOG_DEBUG | ( | ... | ) |
Log an DEBUG level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_DEBUG.
| ... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_DEBUG_IF | ( | log_cond, | |
| log... ) |
Conditionally log an DEBUG level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_DEBUG.
| log_cond | Condition that must be true for the message to be logged |
| log... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_ERROR | ( | ... | ) |
Log an ERROR level message Used for critical errors that may prevent normal operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_ERROR.
| ... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_ERROR_IF | ( | log_cond, | |
| log... ) |
Conditionally log an ERROR level message Used for critical errors that may prevent normal operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_ERROR.
| log_cond | Condition that must be true for the message to be logged |
| log... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_IF | ( | log_type, | |
| log_cond, | |||
| log_fmt, | |||
| log_arg... ) |
Conditional logging macro.
Only outputs a log message if the specified condition is true.
| log_type | Type/level of the log message |
| log_cond | Condition that must be true for the message to be logged |
| log_fmt | Format string for the message |
| log_arg | Variable arguments for format string |
| #define UNIOT_LOG_INFO | ( | ... | ) |
Log an INFO level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_INFO.
| ... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_INFO_IF | ( | log_cond, | |
| log... ) |
Conditionally log an INFO level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_INFO.
| log_cond | Condition that must be true for the message to be logged |
| log... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_LEVEL_DEBUG 3 |
| #define UNIOT_LOG_LEVEL_ERROR 0 |
Log level definitions.
Defines the various logging levels in order of verbosity:
| #define UNIOT_LOG_LEVEL_INFO 2 |
| #define UNIOT_LOG_LEVEL_TRACE 4 |
| #define UNIOT_LOG_LEVEL_WARN 1 |
| #define UNIOT_LOG_PRINT | ( | ... | ) |
Print to the logging stream.
Outputs text to the configured logging stream if available. Can be overridden by defining UNIOT_LOG_PRINT before including this file.
| #define UNIOT_LOG_SET_READY | ( | ) |
Initialize the logging system.
Sets up the serial port for logging if not already initialized. Can be overridden by defining UNIOT_LOG_SET_READY before including this file.
| #define UNIOT_LOG_STREAM Serial |
Default log level.
Sets the default logging level if not defined elsewhere. Can be overridden by defining UNIOT_LOG_LEVEL before including this file.
Logging implementation when enabled
When UNIOT_LOG_ENABLED is defined, this section provides the actual implementation of the logging functionality.
Default serial port for logging
Can be overridden by defining UNIOT_LOG_STREAM before including this file.
| #define UNIOT_LOG_TRACE | ( | ... | ) |
Log an TRACE level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_TRACE.
| ... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_TRACE_IF | ( | log_cond, | |
| log... ) |
Conditionally log an TRACE level message Used for general information about system operation. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_TRACE.
| log_cond | Condition that must be true for the message to be logged |
| log... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_WARN | ( | ... | ) |
Log an WARN level message Used for warnings about potentially problematic situations. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_WARN.
| ... | Printf-style format string followed by arguments |
| #define UNIOT_LOG_WARN_IF | ( | log_cond, | |
| log... ) |
Conditionally log an WARN level message Used for warnings about potentially problematic situations. Only compiled if UNIOT_LOG_LEVEL is at least UNIOT_LOG_LEVEL_WARN.
| log_cond | Condition that must be true for the message to be logged |
| log... | Printf-style format string followed by arguments |