forked from Gingeropolous/wolf-xmr-miner
-
Notifications
You must be signed in to change notification settings - Fork 22
/
log.c
42 lines (33 loc) · 755 Bytes
/
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
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <pthread.h>
#include "minerlog.h"
pthread_mutex_t LogMutex = PTHREAD_MUTEX_INITIALIZER;
static uint32_t LogLevel = LOG_INVALID;
void Log(uint32_t MsgLevel, char *Msg, ...)
{
va_list args;
time_t rawtime;
char timebuf[128];
struct tm *curtime;
if(MsgLevel <= LogLevel && LogLevel != LOG_INVALID)
{
time(&rawtime);
curtime = localtime(&rawtime);
strftime(timebuf, 128, "[%H:%M:%S] ", curtime);
pthread_mutex_lock(&LogMutex);
printf(timebuf);
va_start(args, Msg);
vprintf(Msg, args);
va_end(args);
putchar('\n');
pthread_mutex_unlock(&LogMutex);
}
return;
}
void InitLogging(uint32_t DesiredLogLevel)
{
LogLevel = DesiredLogLevel;
return;
}