-
Notifications
You must be signed in to change notification settings - Fork 3
/
Logging.c
73 lines (60 loc) · 1.83 KB
/
Logging.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* @(#)highwire/Logging.c
*
* This module provides logging functionality for the HighWire HTML browser.
* It's usefull to inform the user about rendering time, HTML errors, ...
* It's possible to extend this to a log file, opend on an user command.
* Rainer Seitel, 2002-04-15
*/
#include <stdarg.h>
#include <stdio.h>
#include "global.h"
#include "Logging.h"
/* With key F7 the user can switch on logging, keyinput.c.
*/
BOOL logging_is_on = FALSE;
void init_logging(void)
{
fprintf(stdout, "\33H\33v"); /* cursor home, enable line wrap */
}
/* errprintf() is for possible errors in HighWire.
* Same parameters as printf().
*
* VT52 console text colors: 0: white, 1: red, 2: green, 3: yellow, 4: blue,
* 5: magenta, 6: cyan, 7: light grey, 8: dark grey, 9: dark red,
* 10':': dark green, 11';': ochre, 12'<': dark blue, 13'=': dark magenta,
* 14'>': dark cyan, 15'?': black.
*/
void errprintf(const char *s, ...)
{
va_list arglist;
if (!ignore_colours)
fprintf(stderr, "\33c7\33b1HighWire: "); /* print error line in red */
else
fprintf(stderr, "\33pHighWire:\33q "); /* print "HighWire:" inverse */
va_start(arglist, s);
vfprintf(stderr, s, arglist);
va_end(arglist);
if (!ignore_colours)
fprintf(stderr, "\33b?"); /* print in black */
}
/* logprintf() is for verbose information for the user.
* Display on users request.
* Same parameters as printf().
*/
void logprintf(const short color, const char *s, ...)
{
va_list arglist;
if (logging_is_on) {
if (!ignore_colours)
/* print "HighWire:" in blue, the rest in 'color' */
fprintf(stdout, "\33c7\33b4HighWire:\33b%c ", (int)color);
else
/* print "HighWire:" inverse */
fprintf(stdout, "\33pHighWire:\33q ");
va_start(arglist, s);
vfprintf(stdout, s, arglist);
va_end(arglist);
if (!ignore_colours)
fprintf(stdout, "\33b?"); /* print in black */
}
}