Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 1 | #include <stdarg.h> |
| 2 | #include <stdio.h> |
Marat Dukhan | b2fc4ab | 2018-02-19 22:43:26 -0800 | [diff] [blame] | 3 | #ifndef _WIN32 |
| 4 | #include <unistd.h> |
| 5 | #endif |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 6 | |
| 7 | #include <log.h> |
| 8 | |
| 9 | #if CPUINFO_LOG_LEVEL >= CPUINFO_LOG_ERROR |
| 10 | void cpuinfo_log_error(const char* format, ...) { |
| 11 | va_list args; |
| 12 | va_start(args, format); |
| 13 | |
Marat Dukhan | b2fc4ab | 2018-02-19 22:43:26 -0800 | [diff] [blame] | 14 | #if defined(__ANDROID__) || defined(_WIN32) |
Marat Dukhan | 59d3071 | 2017-05-08 04:43:52 -0400 | [diff] [blame] | 15 | fprintf(stderr, "Error: "); |
| 16 | vfprintf(stderr, format, args); |
| 17 | fprintf(stderr, "\n"); |
| 18 | fflush(stderr); |
| 19 | #else |
| 20 | dprintf(STDERR_FILENO, "Error: "); |
| 21 | vdprintf(STDERR_FILENO, format, args); |
| 22 | dprintf(STDERR_FILENO, "\n"); |
| 23 | #endif |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 24 | |
| 25 | va_end(args); |
| 26 | } |
| 27 | #endif |
| 28 | |
| 29 | #if CPUINFO_LOG_LEVEL >= CPUINFO_LOG_WARNING |
| 30 | void cpuinfo_log_warning(const char* format, ...) { |
| 31 | va_list args; |
| 32 | va_start(args, format); |
| 33 | |
Marat Dukhan | b2fc4ab | 2018-02-19 22:43:26 -0800 | [diff] [blame] | 34 | #if defined(__ANDROID__) || defined(_WIN32) |
Marat Dukhan | 59d3071 | 2017-05-08 04:43:52 -0400 | [diff] [blame] | 35 | fprintf(stderr, "Warning: "); |
| 36 | vfprintf(stderr, format, args); |
| 37 | fprintf(stderr, "\n"); |
| 38 | fflush(stderr); |
| 39 | #else |
| 40 | dprintf(STDERR_FILENO, "Warning: "); |
| 41 | vdprintf(STDERR_FILENO, format, args); |
| 42 | dprintf(STDERR_FILENO, "\n"); |
| 43 | #endif |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 44 | |
| 45 | va_end(args); |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | #if CPUINFO_LOG_LEVEL >= CPUINFO_LOG_INFO |
| 50 | void cpuinfo_log_info(const char* format, ...) { |
| 51 | va_list args; |
| 52 | va_start(args, format); |
| 53 | |
Marat Dukhan | b2fc4ab | 2018-02-19 22:43:26 -0800 | [diff] [blame] | 54 | #if defined(__ANDROID__) || defined(_WIN32) |
Marat Dukhan | a8fb3dd | 2017-08-09 13:49:39 -0700 | [diff] [blame] | 55 | printf("Note: "); |
Marat Dukhan | 59d3071 | 2017-05-08 04:43:52 -0400 | [diff] [blame] | 56 | vprintf(format, args); |
| 57 | printf("\n"); |
| 58 | fflush(stdout); |
| 59 | #else |
| 60 | vdprintf(STDOUT_FILENO, format, args); |
| 61 | dprintf(STDOUT_FILENO, "\n"); |
| 62 | #endif |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 63 | |
| 64 | va_end(args); |
| 65 | } |
| 66 | #endif |
| 67 | |
| 68 | #if CPUINFO_LOG_LEVEL >= CPUINFO_LOG_DEBUG |
| 69 | void cpuinfo_log_debug(const char* format, ...) { |
| 70 | va_list args; |
| 71 | va_start(args, format); |
| 72 | |
Marat Dukhan | b2fc4ab | 2018-02-19 22:43:26 -0800 | [diff] [blame] | 73 | #if defined(__ANDROID__) || defined(_WIN32) |
Marat Dukhan | a8fb3dd | 2017-08-09 13:49:39 -0700 | [diff] [blame] | 74 | printf("Debug: "); |
Marat Dukhan | 59d3071 | 2017-05-08 04:43:52 -0400 | [diff] [blame] | 75 | vprintf(format, args); |
| 76 | printf("\n"); |
| 77 | fflush(stdout); |
| 78 | #else |
| 79 | vdprintf(STDOUT_FILENO, format, args); |
| 80 | dprintf(STDOUT_FILENO, "\n"); |
| 81 | #endif |
Marat Dukhan | 547fa36 | 2017-03-03 02:47:26 -0500 | [diff] [blame] | 82 | |
| 83 | va_end(args); |
| 84 | } |
| 85 | #endif |