disk8: Initial commit
[pdp8.git] / sw / disk8 / src / logging.h
... / ...
CommitLineData
1/* Logging facilities */
2
3/*
4 * Macros, all printf style:
5 *
6 * ERR(...), ERROR(...) - Always printed, errcount is incremented.
7 * WARN(...), WARNING(...) - Printed if verbosity_level>0
8 * MSG(...), MESSAGE(...), INFO(...) - Printed if verbosity_level>1
9 * DBG(...), DEBUG(...) - Printed if verbosity_level>2
10 *
11 * Default verbosity level is 1, warnings and errors displayed.
12 */
13
14#ifndef LOGGING_H
15#define LOGGING_H
16
17#include <stdio.h>
18
19/* Global variable containing the program's runtime verbosity level */
20extern int verbosity_level;
21
22/* Global variable containing the program's error count */
23extern int error_count;
24
25/* Global variable containing the program's warning count */
26extern int warn_count;
27
28/* Global variable containing the program's message count */
29extern int msg_count;
30
31/* Show the log summary */
32extern void log_summary();
33
34/* Exit program with logging summary */
35void exit_program(int status);
36
37#define ERROR(...){ \
38 fprintf(stderr," ERROR: " __VA_ARGS__); \
39 error_count++; \
40 }
41
42#define ERR(...) ERROR(__VA_ARGS__)
43
44#define WARNING(...){ \
45 if (verbosity_level>0) fprintf(stderr,"WARNING: " __VA_ARGS__); \
46 warn_count++; \
47 }
48
49#define WARN(...) WARNING(__VA_ARGS__)
50
51#define INFO(...){ \
52 if (verbosity_level>1) fprintf(stderr, " INFO: " __VA_ARGS__); \
53 msg_count++; \
54 }
55
56#define MESSAGE(...) INFO(__VA_ARGS__)
57
58#define MSG(...) MESSAGE(__VA_ARGS__)
59
60#define DEBUG(...){ \
61 if (verbosity_level>2) fprintf(stderr," DEBUG: " __VA_ARGS__);\
62 }
63#define DBG(...) DEBUG(__VA_ARGS__)
64
65
66#endif
67
68
69