SELKIELogger  1.0.0
logging.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Swansea University
3  *
4  * This file is part of the SELKIELogger suite of tools.
5  *
6  * SELKIELogger is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation, either version 3 of the License, or (at your option)
9  * any later version.
10  *
11  * SELKIELogger is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this SELKIELogger product.
18  * If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef SELKIELoggerBase_Logging
22 #define SELKIELoggerBase_Logging
23 #include <stdarg.h>
24 #include <stdbool.h>
25 #include <stdio.h>
26 
40 typedef struct {
41  bool started;
42  bool shutdown;
43  int verbose;
44  FILE *log;
45  int logverbose;
47 
49 void log_error(const program_state *s, const char *format, ...) __attribute__((format(__printf__, 2, 3)));
50 
52 void log_warning(const program_state *s, const char *format, ...) __attribute__((format(__printf__, 2, 3)));
53 
55 void log_info(const program_state *s, const int level, const char *format, ...)
56  __attribute__((format(__printf__, 3, 4)));
57 
59 FILE *openSerialNumberedFile(const char *prefix, const char *extension, char **name);
60 
64 #endif
void destroy_program_state(program_state *s)
Cleanly destroy program state.
Definition: logging.c:207
FILE * openSerialNumberedFile(const char *prefix, const char *extension, char **name)
Open dated, serial numbered file with given prefix and extension.
Definition: logging.c:169
void log_info(const program_state *s, const int level, const char *format,...)
Output formatted information message at a given level.
Definition: logging.c:125
void log_warning(const program_state *s, const char *format,...)
Output formatted warning message.
Definition: logging.c:86
void log_error(const program_state *s, const char *format,...)
Output formatted error message.
Definition: logging.c:47
Program state and logging information.
Definition: logging.h:40
int logverbose
Current log verbosity (file output)
Definition: logging.h:45
int verbose
Current log verbosity (console output)
Definition: logging.h:43
bool started
Indicates startup completed.
Definition: logging.h:41
FILE * log
Log file.
Definition: logging.h:44
bool shutdown
Indicates shutdown begun.
Definition: logging.h:42