blob: 65fac8c804c0db5ecbec7d9f5966d6abbcc54cf4 [file] [log] [blame]
Marat Dukhan547fa362017-03-03 02:47:26 -05001#include <stdarg.h>
2#include <stdio.h>
Marat Dukhanb2fc4ab2018-02-19 22:43:26 -08003#ifndef _WIN32
4 #include <unistd.h>
5#endif
Marat Dukhan547fa362017-03-03 02:47:26 -05006
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 Dukhanb2fc4ab2018-02-19 22:43:26 -080014 #if defined(__ANDROID__) || defined(_WIN32)
Marat Dukhan59d30712017-05-08 04:43:52 -040015 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 Dukhan547fa362017-03-03 02:47:26 -050024
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 Dukhanb2fc4ab2018-02-19 22:43:26 -080034 #if defined(__ANDROID__) || defined(_WIN32)
Marat Dukhan59d30712017-05-08 04:43:52 -040035 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 Dukhan547fa362017-03-03 02:47:26 -050044
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 Dukhanb2fc4ab2018-02-19 22:43:26 -080054 #if defined(__ANDROID__) || defined(_WIN32)
Marat Dukhana8fb3dd2017-08-09 13:49:39 -070055 printf("Note: ");
Marat Dukhan59d30712017-05-08 04:43:52 -040056 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 Dukhan547fa362017-03-03 02:47:26 -050063
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 Dukhanb2fc4ab2018-02-19 22:43:26 -080073 #if defined(__ANDROID__) || defined(_WIN32)
Marat Dukhana8fb3dd2017-08-09 13:49:39 -070074 printf("Debug: ");
Marat Dukhan59d30712017-05-08 04:43:52 -040075 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 Dukhan547fa362017-03-03 02:47:26 -050082
83 va_end(args);
84 }
85#endif