|
| 1 | +/* |
| 2 | + * boxes - Command line filter to draw/remove ASCII boxes around text |
| 3 | + * Copyright (c) 1999-2023 Thomas Jensen and the boxes contributors |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public |
| 6 | + * License, version 3, as published by the Free Software Foundation. |
| 7 | + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 8 | + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 9 | + * details. |
| 10 | + * You should have received a copy of the GNU General Public License along with this program. |
| 11 | + * If not, see <https://www.gnu.org/licenses/>. |
| 12 | + * |
| 13 | +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 14 | + */ |
| 15 | + |
| 16 | +/* |
| 17 | + * Simple makeshift log facility. |
| 18 | + */ |
| 19 | + |
| 20 | +#ifndef LOGGING_H |
| 21 | +#define LOGGING_H |
| 22 | + |
| 23 | + |
| 24 | +typedef enum _log_level_t { |
| 25 | + /** the finest log level */ |
| 26 | + TRACE, |
| 27 | + |
| 28 | + /** a debug message, should be called `DEBUG` */ |
| 29 | + DBG, |
| 30 | + |
| 31 | + /** normal informational message */ |
| 32 | + INFO, |
| 33 | + |
| 34 | + /** a warning message, which should not happen, but can be tolerated */ |
| 35 | + WARN, |
| 36 | + |
| 37 | + /** an error message, normally this will also lead to abnormal program termination */ |
| 38 | + ERROR |
| 39 | +} log_level_t; |
| 40 | + |
| 41 | + |
| 42 | +/** currently active log level, determine whether a message gets printed */ |
| 43 | +extern log_level_t current_log_level; |
| 44 | + |
| 45 | + |
| 46 | +/** log level names for printing */ |
| 47 | +extern char *log_level_name[]; |
| 48 | + |
| 49 | + |
| 50 | +/** |
| 51 | + * Print a log message. Log messages of level INFO will be printed in `stdout`, others on `stderr`. |
| 52 | + * @param log_level the log level |
| 53 | + * @param module the module name as per `__FILE__` |
| 54 | + * @param format format string for the mesage, followed by the placeholder arguments |
| 55 | + */ |
| 56 | +void log(log_level_t log_level, const char *module, const char *format, ...); |
| 57 | + |
| 58 | + |
| 59 | +#endif |
| 60 | + |
| 61 | +/* vim: set cindent sw=4: */ |
0 commit comments