Commit | Line | Data |
---|---|---|
59f0d218 FF |
1 | diff -Nur /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/syslog.h ./usr/include/syslog.h |
2 | --- /Users/fornwall/lib/android-ndk/platforms/android-18/arch-arm/usr/include/syslog.h 2012-08-21 07:23:12.000000000 +0200 | |
3 | +++ ./usr/include/syslog.h 2014-01-29 17:51:55.000000000 +0100 | |
4 | @@ -31,6 +31,8 @@ | |
5 | #include <stdio.h> | |
6 | #include <sys/cdefs.h> | |
7 | #include <stdarg.h> | |
8 | +#include <android/log.h> /* for __android_log_vprint() */ | |
9 | +#include <unistd.h> /* for getpid() */ | |
10 | ||
11 | __BEGIN_DECLS | |
12 | ||
4ba80ad5 | 13 | @@ -111,6 +112,64 @@ |
59f0d218 FF |
14 | extern void syslog_r(int, struct syslog_data *, const char *, ...); |
15 | extern void vsyslog_r(int, struct syslog_data *, const char *, va_list); | |
16 | ||
17 | +extern /*const*/ char* __progname; | |
5c36f4e0 | 18 | +static __inline__ void android_polyfill_openlog(const char* a, int b, int c) { |
59f0d218 FF |
19 | + (void) a; |
20 | + (void) b; | |
21 | + (void) c; | |
22 | +} | |
5c36f4e0 | 23 | +static __inline__ void android_polyfill_closelog() {} |
59f0d218 | 24 | + |
5c36f4e0 | 25 | +static __inline__ void android_polyfill_vsyslog(int syslog_priority, char const* format, va_list ap) |
59f0d218 | 26 | +{ |
4ba80ad5 | 27 | + android_LogPriority a = ANDROID_LOG_ERROR; |
59f0d218 | 28 | + switch (syslog_priority) { |
4ba80ad5 FF |
29 | + case LOG_WARNING: a = ANDROID_LOG_WARN; break; |
30 | + case LOG_NOTICE : a = ANDROID_LOG_INFO; break; | |
31 | + case LOG_INFO: a = ANDROID_LOG_INFO; break; | |
32 | + case LOG_DEBUG: a = ANDROID_LOG_DEBUG; break; | |
59f0d218 FF |
33 | + } |
34 | + char* syslog_text; | |
35 | + if (vasprintf(&syslog_text, format, ap) == -1) { | |
36 | + __android_log_vprint(a, "syslog", format, ap); | |
37 | + return; | |
38 | + } | |
39 | + __android_log_print(a, "syslog", "%s - %s", __progname, syslog_text); | |
40 | + free(syslog_text); | |
41 | +} | |
42 | + | |
5c36f4e0 | 43 | +static __inline__ void android_polyfill_syslog(int priority, const char* format, ...) |
59f0d218 FF |
44 | +{ |
45 | + va_list myargs; | |
46 | + va_start(myargs, format); | |
47 | + android_polyfill_vsyslog(priority, format, myargs); | |
48 | + va_end(myargs); | |
49 | +} | |
50 | + | |
5c36f4e0 | 51 | +static __inline__ void android_polyfill_syslog_r(int syslog_priority, void* d, const char* format, ...) |
59f0d218 FF |
52 | +{ |
53 | + (void) d; | |
54 | + va_list myargs; | |
55 | + va_start(myargs, format); | |
56 | + android_polyfill_vsyslog(syslog_priority, format, myargs); | |
57 | + va_end(myargs); | |
58 | +} | |
59 | + | |
5c36f4e0 | 60 | +static __inline__ void android_polyfill_vsyslog_r(int syslog_priority, void* d, const char* fmt, va_list ap) |
59f0d218 FF |
61 | +{ |
62 | + (void) d; | |
63 | + android_polyfill_vsyslog(syslog_priority, fmt, ap); | |
64 | +} | |
65 | + | |
66 | +#define openlog android_polyfill_openlog | |
67 | +#define closelog android_polyfill_closelog | |
68 | + | |
69 | +#define syslog android_polyfill_syslog | |
70 | +#define syslog_r android_polyfill_syslog_r | |
71 | + | |
72 | +#define vsyslog android_polyfill_vsyslog | |
73 | +#define vsyslog_r android_polyfill_vsyslog_r | |
74 | + | |
75 | __END_DECLS | |
76 | ||
77 | #endif /* _SYSLOG_H */ |