disk8: Initial commit
[pdp8.git] / sw / disk8 / src / logging.c
CommitLineData
919757fd
PH
1/* Logging operations for our little program */
2
3#include "logging.h"
4#include <stdlib.h>
5
6/* Global variable containing the program's runtime verbosity level */
7int verbosity_level=1;
8
9/* Global variable containing the program's error count */
10int error_count=0;
11
12/* Global variable containing the program's warning count */
13int warn_count=0;
14
15/* Global variable containing the program's message count */
16int msg_count=0;
17
18void log_summary(){
19 if (verbosity_level>1){
20 fprintf(stderr,
21 "\n====================\n Errors: %i\nWarnings: %i\nMessages: %i\n",
22 error_count,warn_count,msg_count);
23 } else if (verbosity_level){
24 if (warn_count || error_count){
25 fprintf(stderr,
26 "\n====================\n Errors: %i\nWarnings: %i\n",
27 error_count,warn_count);
28 }
29 }
30}
31
32void exit_program(int status){
33 log_summary();
34 if ((verbosity_level>1)||(verbosity_level && (status !=0)))
35 fprintf(stderr,"\nExit status: %i\n",status);
36 exit(status);
37}