-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall_log.c
97 lines (81 loc) · 1.73 KB
/
install_log.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Functions to log messages */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "install_log.h"
#include "install_ui.h"
#include "log.h"
extern Install_UI UI;
static install_log *log = NULL;
void log_init(int level)
{
log = create_log((log_level) level);
if ( ! log ) {
fprintf(stderr, _("Out of memory\n"));
}
}
void log_exit(void)
{
destroy_log(log);
}
void log_debug(const char *fmt, ...)
{
va_list ap;
char buf[BUFSIZ];
va_start(ap, fmt);
vsnprintf(buf, BUFSIZ, fmt, ap);
va_end(ap);
print_log(log, LOG_DEBUG, "%s\n", buf);
}
void log_quiet(const char *fmt, ...)
{
va_list ap;
char buf[BUFSIZ];
va_start(ap, fmt);
vsnprintf(buf, BUFSIZ, fmt, ap);
va_end(ap);
print_log(log, LOG_QUIET, "%s\n", buf);
}
void log_normal(const char *fmt, ...)
{
va_list ap;
char buf[BUFSIZ];
va_start(ap, fmt);
vsnprintf(buf, BUFSIZ, fmt, ap);
va_end(ap);
print_log(log, LOG_NORMAL, "%s\n", buf);
}
void log_warning(const char *fmt, ...)
{
va_list ap;
char buf[BUFSIZ];
va_start(ap, fmt);
vsnprintf(buf, BUFSIZ, fmt, ap);
va_end(ap);
print_log(log, LOG_WARNING, "%s\n", buf);
}
void log_fatal(const char *fmt, ...)
{
va_list ap;
char buf[BUFSIZ];
va_start(ap, fmt);
vsnprintf(buf, BUFSIZ, fmt, ap);
va_end(ap);
print_log(log, LOG_FATAL, "%s\n", buf);
ui_fatal_error("%s", buf);
}
/* Displays a dialog using the UI code and abort the installation */
void ui_fatal_error(const char *txt, ...)
{
va_list ap;
char buf[BUFSIZ];
va_start(ap, txt);
vsnprintf(buf, BUFSIZ, txt, ap);
va_end(ap);
if ( UI.prompt ) {
UI.prompt(buf, RESPONSE_OK);
} else {
fputs(buf, stderr);
}
abort_install();
}