source: trunk/MagicSoft/Simulation/Detector/ReflectorII/diag.c

Last change on this file was 775, checked in by domingo, 24 years ago
Small change: two "#" put on their place
File size: 2.1 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <stdarg.h>
4#include "version.h"
5#include "diag.h"
6
7/* To display errors on stdout, comment line below */
8#define ERR_TO_STDERR
9
10#ifdef ERR_TO_STDERR
11#define STDERR stderr
12#elif
13#define STDERR stdout
14#endif
15
16enum VerboseLevel /* verbose levels */
17{ VERBOSE_QUIET,
18 VERBOSE_MINIMAL,
19 VERBOSE_NORMAL,
20 VERBOSE_MAXIMAL };
21
22#define VERBOSE_DEFAULT VERBOSE_QUIET
23
24static int verbose = VERBOSE_DEFAULT;
25
26void SetVerbose(int vlevel)
27{ verbose = (vlevel < VERBOSE_QUIET) ? VERBOSE_QUIET
28 : (vlevel > VERBOSE_MAXIMAL) ? VERBOSE_MAXIMAL
29 : vlevel;
30} /* end of SetVerbose */
31
32void FatalError(const char *fatal_string, ...)
33{ va_list args;
34 extern void clean(void);
35
36 /* Display signature */
37 fprintf(STDERR, "\a\n *** %s %s: ", QUOTE(PROGRAM), QUOTE(VERSION));
38
39 /* Display error message */
40 va_start(args, fatal_string);
41 vfprintf(STDERR, fatal_string, args);
42 va_end(args);
43
44 /* Byebye message */
45 fputs(" *** Exiting Reflector.\n\n", STDERR);
46
47 /* Abort and exit */
48 clean();
49 exit(1);
50} /* end of FatalError */
51
52void Error(const char *error_string, ...)
53{ va_list args;
54
55 /* Display signature */
56 fprintf(STDERR, "\a\n *** %s %s: ", QUOTE(PROGRAM), QUOTE(VERSION));
57
58 /* Display error message */
59 va_start(args, error_string);
60 vfprintf(STDERR, error_string, args);
61 va_end(args);
62
63 /* Skip line */
64 fputc('\n', STDERR);
65} /* end of Error */
66
67void Message(const char *message_string, ...)
68{ va_list args;
69
70 /* Display message */
71 va_start(args, message_string);
72 vprintf(message_string, args);
73 va_end(args);
74} /* end of Message */
75
76void Log(const char *log_string, ...)
77{ va_list args;
78
79 /* Display message */
80 va_start(args, log_string);
81 if (verbose >= VERBOSE_MINIMAL)
82 vprintf(log_string, args);
83 va_end(args);
84} /* end of Log */
85
86void Debug(const char *log_string, ...)
87{ va_list args;
88
89 /* Display message */
90 va_start(args, log_string);
91 if (verbose == VERBOSE_MAXIMAL)
92 vprintf(log_string, args);
93 va_end(args);
94} /* end of Debug */
Note: See TracBrowser for help on using the repository browser.