Talustus | 3019a91 | 2013-04-06 11:50:07 +0200 | [diff] [blame] | 1 | /** |
| 2 | * fb2png Save screenshot into .png. |
| 3 | * |
| 4 | * Copyright (C) 2012 Kyan <kyan.ql.he@gmail.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along |
| 17 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | #ifndef __KYAN_LOG_H__ |
| 21 | #define __KYAN_LOG_H__ |
| 22 | |
| 23 | #include <errno.h> |
| 24 | |
| 25 | #ifdef ANDROID_XXX |
| 26 | |
| 27 | #ifndef LOG_TAG |
| 28 | #define LOG_TAG "tag" |
| 29 | #endif |
| 30 | |
| 31 | #include <android/log.h> |
| 32 | |
| 33 | #define D LOGD |
| 34 | #define E LOGE |
| 35 | |
| 36 | #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__) |
| 37 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , LOG_TAG, __VA_ARGS__) |
| 38 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO , LOG_TAG, __VA_ARGS__) |
| 39 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN , LOG_TAG, __VA_ARGS__) |
| 40 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , LOG_TAG, __VA_ARGS__) |
| 41 | |
| 42 | #else /* ANDROID */ |
| 43 | |
| 44 | #include <stdio.h> |
| 45 | #include <stdlib.h> |
| 46 | #include <stdarg.h> |
| 47 | |
| 48 | #if DEBUG == 1 |
| 49 | |
| 50 | #define LOG_FUNCTION_NAME \ |
| 51 | fprintf(stderr, "\033[0;1;31m__func__: %s\033[0;0m\n", __FUNCTION__); |
| 52 | |
| 53 | #else |
| 54 | |
| 55 | #define LOG_FUNCTION_NAME |
| 56 | |
| 57 | #endif |
| 58 | |
| 59 | static void |
| 60 | D(const char *msg, ...) |
| 61 | { |
| 62 | va_list ap; |
| 63 | |
| 64 | va_start (ap, msg); |
| 65 | vfprintf(stdout, msg, ap); |
| 66 | fprintf(stdout, "\n"); |
| 67 | va_end (ap); |
| 68 | fflush(stdout); |
| 69 | } |
| 70 | |
| 71 | static void |
| 72 | E(const char *msg, ...) |
| 73 | { |
| 74 | va_list ap; |
| 75 | |
| 76 | va_start (ap, msg); |
| 77 | vfprintf(stderr, msg, ap); |
| 78 | fprintf(stderr, ", %s", strerror(errno)); |
| 79 | fprintf(stderr, "\n"); |
| 80 | va_end (ap); |
| 81 | } |
| 82 | |
| 83 | #endif /* ANDROID */ |
| 84 | |
| 85 | #endif |