blob: 2b7cf8cecc0b9ef18375918d57cc24dd00eb2502 [file] [log] [blame]
Talustus3019a912013-04-06 11:50:07 +02001/**
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>
Matt Mower908a2772017-01-11 15:31:00 -060024#include <string.h>
Talustus3019a912013-04-06 11:50:07 +020025
26#ifdef ANDROID_XXX
27
28#ifndef LOG_TAG
29#define LOG_TAG "tag"
30#endif
31
32#include <android/log.h>
33
34#define D LOGD
35#define E LOGE
36
37#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
38#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , LOG_TAG, __VA_ARGS__)
39#define LOGI(...) __android_log_print(ANDROID_LOG_INFO , LOG_TAG, __VA_ARGS__)
40#define LOGW(...) __android_log_print(ANDROID_LOG_WARN , LOG_TAG, __VA_ARGS__)
41#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , LOG_TAG, __VA_ARGS__)
42
43#else /* ANDROID */
44
45#include <stdio.h>
46#include <stdlib.h>
47#include <stdarg.h>
48
49#if DEBUG == 1
50
51#define LOG_FUNCTION_NAME \
52 fprintf(stderr, "\033[0;1;31m__func__: %s\033[0;0m\n", __FUNCTION__);
53
54#else
55
56#define LOG_FUNCTION_NAME
57
58#endif
59
60static void
61D(const char *msg, ...)
62{
63 va_list ap;
64
65 va_start (ap, msg);
66 vfprintf(stdout, msg, ap);
67 fprintf(stdout, "\n");
68 va_end (ap);
69 fflush(stdout);
70}
71
72static void
73E(const char *msg, ...)
74{
75 va_list ap;
76
77 va_start (ap, msg);
78 vfprintf(stderr, msg, ap);
79 fprintf(stderr, ", %s", strerror(errno));
80 fprintf(stderr, "\n");
81 va_end (ap);
82}
83
84#endif /* ANDROID */
85
86#endif