2024-08-23 11:53:40 +02:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
|
|
|
* Copyright (C) 2024 Thomas Kolb
|
|
|
|
*/
|
|
|
|
|
2024-05-28 23:53:11 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015-2024 Thomas Kolb
|
|
|
|
*
|
|
|
|
* 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 LOGGER_H
|
|
|
|
#define LOGGER_H
|
|
|
|
|
|
|
|
#include <semaphore.h>
|
|
|
|
|
|
|
|
static const int LVL_FATAL = 0; /*!< Fatal message level */
|
|
|
|
static const int LVL_ERR = 5; /*!< Error message level */
|
|
|
|
static const int LVL_WARN = 50; /*!< Warning message level */
|
|
|
|
static const int LVL_INFO = 100; /*!< Information message level */
|
|
|
|
static const int LVL_DEBUG = 200; /*!< Debug message level */
|
|
|
|
static const int LVL_DUMP = 500; /*!< Dump message level */
|
|
|
|
|
|
|
|
extern sem_t logger_semaphore;
|
|
|
|
extern int logger_verbosity;
|
|
|
|
extern int logger_use_colors;
|
|
|
|
|
|
|
|
void logger_init(void);
|
|
|
|
void logger_shutdown(void);
|
|
|
|
void logger_enable_colors(int enable);
|
|
|
|
void logger_set_verbosity(int verbosity);
|
|
|
|
|
2024-07-20 00:04:32 +02:00
|
|
|
void logger_log(int level, const char *module_name, const char *format, ...);
|
|
|
|
|
|
|
|
#ifndef LOGGER_MODULE_NAME
|
|
|
|
#define LOGGER_MODULE_NAME "undef"
|
|
|
|
#endif
|
2024-05-28 23:53:11 +02:00
|
|
|
|
|
|
|
#ifndef LOGGER_DISABLE_ALL
|
2024-07-20 00:04:32 +02:00
|
|
|
#define LOG(level, ...) logger_log(level, LOGGER_MODULE_NAME, __VA_ARGS__)
|
2024-05-28 23:53:11 +02:00
|
|
|
#else
|
|
|
|
#define LOG(level, ...) {}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // LOGGER_H
|