| 6 |
| * Copyright Nikolai Kudashov, 2015. |
| 7 | */ |
| 8 |
| 9 | #include <stdio.h> |
| 10 | #include <stdarg.h> |
| 11 | #include "FileLog.h" |
| 12 |
| 13 | #ifdef ANDROID |
| 14 | #include <android/log.h> |
| 15 | #endif |
| 16 |
| 17 | void FileLog::e(const char *message, ...) { |
| 18 | va_list argptr; |
| 19 | va_start(argptr, message); |
| 20 | #ifdef ANDROID |
| 21 | __android_log_vprint(ANDROID_LOG_ERROR, "tgnet", message, argptr); |
| 22 | #else |
| 23 | printf("error: "); |
| 24 | vprintf(message, argptr); |
| 25 | printf("\n"); |
| 26 | fflush(stdout); |
| 27 | #endif |
| 28 | va_end(argptr); |
| 29 | } |
| 30 |
| 31 | void FileLog::w(const char *message, ...) { |
| 32 | va_list argptr; |
| 33 | va_start(argptr, message); |
| 34 | #ifdef ANDROID |
| 35 | __android_log_vprint(ANDROID_LOG_WARN, "tgnet", message, argptr); |
| 36 | #else |
| 37 | printf("warning: "); |
| 38 | vprintf(message, argptr); |
| 39 | printf("\n"); |
| 40 | fflush(stdout); |
| 41 | #endif |
| 42 | va_end(argptr); |
| 43 | } |
| 44 |
| 45 | void FileLog::d(const char *message, ...) { |
| 46 | va_list argptr; |
| 47 | va_start(argptr, message); |
| 48 | #ifdef ANDROID |
| 49 | __android_log_vprint(ANDROID_LOG_DEBUG, "tgnet", message, argptr); |
| 50 | #else |
| 51 | printf("debug: "); |
| 52 | vprintf(message, argptr); |
| 53 | printf("\n"); |
| 54 | fflush(stdout); |
| 55 | #endif |
| 56 | va_end(argptr); |
| 57 | } |
| 58 |