mirror of
https://github.com/Kugelschieber/vk-experiments.git
synced 2026-01-18 06:40:27 +00:00
Fixed log levels and time string function.
This commit is contained in:
26
src/log.c
26
src/log.c
@@ -5,33 +5,27 @@
|
|||||||
|
|
||||||
int logLevel = 0;
|
int logLevel = 0;
|
||||||
|
|
||||||
// TODO
|
char* timeNow() {
|
||||||
/*const char* timeStr() {
|
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm * p = localtime(&now);
|
struct tm * p = localtime(&now);
|
||||||
char buffer[25];
|
static char buffer[21];
|
||||||
strftime(buffer, 25, "%Y-%m-%d %H:%M:%S", p);
|
strftime(buffer, 20, "%Y-%m-%d %H:%M:%S", p);
|
||||||
//buffer[24] = '\0';
|
buffer[20] = '\0';
|
||||||
const char* str = buffer;
|
return buffer;
|
||||||
return str;
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
void vkeSetLogLevel(int level) {
|
void vkeSetLogLevel(int level) {
|
||||||
logLevel = level;
|
logLevel = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vkeLogDebug(const char* message) {
|
void vkeLogDebug(const char* message) {
|
||||||
if(logLevel == 0) {
|
if(logLevel < VKE_LOG_ERROR) {
|
||||||
time_t now;
|
printf("%s [DEBUG] %s\n", timeNow(), message);
|
||||||
time(&now);
|
|
||||||
printf("%s [DEBUG] %s\n", ctime(&now), message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vkeLogError(const char* message) {
|
void vkeLogError(const char* message) {
|
||||||
if(logLevel > 0) {
|
if(logLevel < VKE_LOG_ERROR+1) {
|
||||||
time_t now;
|
printf("%s [ERROR] %s\n", timeNow(), message);
|
||||||
time(&now);
|
|
||||||
printf("%s [ERROR] %s\n", ctime(&now), message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user