-
Notifications
You must be signed in to change notification settings - Fork 40
/
log.cpp
47 lines (39 loc) · 907 Bytes
/
log.cpp
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
/** Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License */
#include <stdio.h>
#include <stdarg.h>
#include "log.h"
static int verbose_level = 0;
static bool progressLogging;
void increaseVerboseLevel()
{
verbose_level++;
}
void enableProgressLogging()
{
progressLogging = true;
}
void logError(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fflush(stderr);
}
void _log(const char* fmt, ...)
{
if (verbose_level < 1)
return;
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fflush(stderr);
}
void logProgress(const char* type, int value, int maxValue)
{
if (!progressLogging)
return;
fprintf(stderr, "Progress:%s:%i:%i\n", type, value, maxValue);
fflush(stderr);
}