| 1 |
/* logger.h |
| 2 |
* |
| 3 |
* Copyright 2025 Francois Techene |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
* |
| 18 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef LOGGER_H |
| 22 |
#define LOGGER_H |
| 23 |
|
| 24 |
typedef enum { |
| 25 |
NONE_LEVEL = 0, |
| 26 |
ERROR_LEVEL, |
| 27 |
WARNING_LEVEL, |
| 28 |
INFO_LEVEL, |
| 29 |
DEBUG_LEVEL |
| 30 |
} LogLevel; |
| 31 |
|
| 32 |
typedef enum { |
| 33 |
NONE_OUT = 0, |
| 34 |
CONSOLE_OUT, |
| 35 |
FILE_OUT |
| 36 |
|
| 37 |
} LogOutputMethod; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
typedef struct _Logger { |
| 42 |
|
| 43 |
void (*log) (char* format, ...); |
| 44 |
void (*debug) (char* format, ...); |
| 45 |
void (*info) (char* format, ...); |
| 46 |
void (*warn) (char* format, ...); |
| 47 |
void (*error) (char* format, ...); |
| 48 |
|
| 49 |
char* file_path; |
| 50 |
int output_method; |
| 51 |
int log_level; |
| 52 |
|
| 53 |
|
| 54 |
} Logger; |
| 55 |
|
| 56 |
extern Logger logger; |
| 57 |
|
| 58 |
void init_logger(LogLevel level, |
| 59 |
LogOutputMethod out, |
| 60 |
char* file_path); |
| 61 |
|
| 62 |
void log_debug(char* format, ...); |
| 63 |
void log_info(char* format, ...); |
| 64 |
void log_warn(char* format, ...); |
| 65 |
void log_error(char* format, ...); |
| 66 |
|
| 67 |
void log_to_none(char* format, ...); |
| 68 |
void log_to_console(char* format, ...); |
| 69 |
void log_to_file(char* format, ...); |
| 70 |
|
| 71 |
|
| 72 |
#endif |