forked from uyjulian/zbspac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.c
41 lines (31 loc) · 800 Bytes
/
Logger.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
/**
* @file Logger.c
* @brief Implementation of "the" simple logger.
* @copyright Covered by 2-clause BSD, please refer to license.txt.
* @author CloudiDust
* @date 2010.02
*/
#include <stdio.h>
#include <wchar.h>
#include <stdarg.h>
#include "Logger.h"
static LogLevel logLevel;
void setLogLevel(LogLevel level) {
logLevel = level;
}
void writeLog(LogLevel level, const wchar_t* str, ...) {
if (level > logLevel) return;
va_list args;
va_start(args, str);
vfwprintf(stderr, str, args);
va_end(args);
fputwc(L'\n', stderr);
}
void writeOnlyOnLevel(LogLevel level, const wchar_t* str, ...) {
if (level != logLevel) return;
va_list args;
va_start(args, str);
vfwprintf(stderr, str, args);
va_end(args);
fputwc(L'\n', stderr);
}