SELKIELogger  1.0.0
logTests.c
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 
22 #include "SELKIELoggerBase.h"
23 
40 int main(void) {
41  program_state state = {0};
42  state.verbose = 0;
43  state.log = fopen("/dev/null", "w");
44  log_info(&state, 1, "Hidden message 1");
45  log_info(&state, 0, "Displayed message 1");
46  log_warning(&state, "Warning message during startup");
47  log_error(&state, "Error message during startup");
48  state.started = true;
49  state.verbose++;
50  log_info(&state, 1, "Running state");
51  log_info(&state, 2, "Currently running with verbosity %d", state.verbose);
52  log_warning(&state, "Warning message while running");
53  log_error(&state, "Error message while running");
54  state.shutdown = true;
55  log_info(&state, 1, "Shutting down state");
56  log_warning(&state, "Warning message during shutdown");
57  log_error(&state, "Error message during shutdown");
58  return 0;
59 }
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
int main(void)
Definition: logTests.c:40
Program state and logging information.
Definition: logging.h:40
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