Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/Cherry/Core/include/log.h
2 views
1
/*
2
* Gearcoleco - ColecoVision Emulator
3
* Copyright (C) 2021 Ignacio Sanchez
4
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see http://www.gnu.org/licenses/
17
*
18
*/
19
20
#ifndef LOG_H
21
#define LOG_H
22
23
#include <stdio.h>
24
#include <stdarg.h>
25
#include "definitions.h"
26
27
#if defined(__LIBRETRO__)
28
#include "libretro.h"
29
extern retro_log_printf_t log_cb;
30
#endif
31
32
#if defined(DEBUG_GEARCOLECO)
33
#if defined(__ANDROID__)
34
#include <android/log.h>
35
#define printf(...) __android_log_print(ANDROID_LOG_DEBUG, GG_TITLE, __VA_ARGS__);
36
#endif
37
#define Debug(msg, ...) (Log_func(msg, ##__VA_ARGS__))
38
#else
39
#define Debug(msg, ...)
40
#endif
41
42
#define Log(msg, ...) (Log_func(msg, ##__VA_ARGS__))
43
44
inline void Log_func(const char* const msg, ...)
45
{
46
char buffer[512];
47
va_list args;
48
va_start(args, msg);
49
vsnprintf(buffer, 512, msg, args);
50
va_end(args);
51
52
#if defined(__LIBRETRO__)
53
if (log_cb)
54
{
55
log_cb(RETRO_LOG_INFO, "%s\n", buffer);
56
return;
57
}
58
#endif
59
60
#if defined(DEBUG_GEARCOLECO)
61
static int count = 1;
62
printf("%d: %s\n", count, buffer);
63
count++;
64
#else
65
printf("%s\n", buffer);
66
#endif
67
68
fflush(stdout);
69
}
70
71
#endif /* LOG_H */
72
73