/* =========================================================================
xdp_log - The xdp_log class!
MIT License
Copyright (c) [2023] XDP Interface
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
=========================================================================
*/
#ifndef XDP_LOG_H_INCLUDED
#define XDP_LOG_H_INCLUDED
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
[docs]/**
* Log a message
*
* Args:
* level (int): Log level
* msg (const char *): Variable arg (formated) message to be logged in
*
*/
#define XDP_LOG_MSG(level, msg, ...) xdp_log_msg(XDP_MODULE_NAME, __LINE__, level, msg, ## __VA_ARGS__)
[docs]/**
* Log a hexdump
*
* Args:
* level (int): Log level
* description (const char *): Brief description of the memory to be dumped
* buffer (void *): Buffer to be dumped
* buffer_len (size_t): Length of the buffer to be dumped
*
*/
#define XDP_LOG_HEXDUMP(level, description, buffer, buffer_len) xdp_log_hexdump (XDP_MODULE_NAME, __LINE__, level, description, buffer, buffer_len)
// @warning THE FOLLOWING @INTERFACE BLOCK IS AUTO-GENERATED BY ZPROJECT
// @warning Please edit the model at "api/xdp_log.api" to make changes.
// @interface
// This is a stable class, and may not change except for emergencies. It
// is provided in stable builds.
[docs]/**
* A log level describing events showing step by step execution of your code that can be ignored during the standard operation, but may be useful during extended debugging sessions.
*/
#define XDP_LOG_TRACE 0
[docs]/**
* A log level used for events considered to be useful during software debugging when more granular information is needed.
*/
#define XDP_LOG_DEBUG 1
[docs]/**
* An event happened, the event is purely informative and can be ignored during normal operations.
*/
#define XDP_LOG_INFO 2
[docs]/**
* Unexpected behavior happened inside the application, but it is continuing its work and the key business features are operating as expected.
*/
#define XDP_LOG_WARNING 3
[docs]/**
* One or more functionalities are not working, preventing some functionalities from working correctly.
*/
#define XDP_LOG_ERROR 4
[docs]/**
* One or more key business functionalities are not working and the whole system doesn’t fulfill the business functionalities.
*/
#define XDP_LOG_CRITICAL 5
[docs]/**
* Log levels
*/
#define XDP_LOG_LVLS 6
// Set log level
void
xdp_log_level_set (int level);
// Log message
void
xdp_log_msg (const char *module, int line, int level, const char *format, ...);
// Hexdump
void
xdp_log_hexdump (const char *module, int line, int level, const char *description, void *buffer, size_t buffer_len);
// Self test of this class.
void
xdp_log_test (bool verbose);
// @end
#ifdef __cplusplus
}
#endif
#endif