-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging.cc
62 lines (51 loc) · 1.19 KB
/
logging.cc
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
/*
* VICERA by h34ting4ppliance
* VICasm by h34ting4ppliance
*
* logging.cc
*
* This file contains all the logging functions to make log formatting easier.
* This file has been ported to C++ for the assembler.
*/
#include <cstdio>
#include <cstdlib>
#include <cstdarg>
#include "logging.h"
// Init function
Logging::Logging(const char* fname)
{
filename = fname;
}
// String, String -> None
// writes log
void Logging::log(const char* msg, ...)
{
fprintf(stderr, "\033[1m[#] |%s|\033[0m ", filename);
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, "\n");
}
// String, String -> None
// warning log
void Logging::warn(const char* msg, ...)
{
fprintf(stderr, "\033[1;43m[!] |%s|\033[0;43m ", filename);
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, "\033[0m\n");
}
// String, String -> None
// writes error
void Logging::error(const char* msg, ...)
{
fprintf(stderr, "\033[1;41m[X] |%s|\033[0;41m ", filename);
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, "\033[0m\n");
}