/*1* Gearcoleco - ColecoVision Emulator2* Copyright (C) 2021 Ignacio Sanchez34* This program is free software: you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation, either version 3 of the License, or7* any later version.89* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.1314* You should have received a copy of the GNU General Public License15* along with this program. If not, see http://www.gnu.org/licenses/16*17*/1819#ifndef LOG_H20#define LOG_H2122#include <stdio.h>23#include <stdarg.h>24#include "definitions.h"2526#if defined(__LIBRETRO__)27#include "libretro.h"28extern retro_log_printf_t log_cb;29#endif3031#if defined(DEBUG_GEARCOLECO)32#if defined(__ANDROID__)33#include <android/log.h>34#define printf(...) __android_log_print(ANDROID_LOG_DEBUG, GG_TITLE, __VA_ARGS__);35#endif36#define Debug(msg, ...) (Log_func(msg, ##__VA_ARGS__))37#else38#define Debug(msg, ...)39#endif4041#define Log(msg, ...) (Log_func(msg, ##__VA_ARGS__))4243inline void Log_func(const char* const msg, ...)44{45char buffer[512];46va_list args;47va_start(args, msg);48vsnprintf(buffer, 512, msg, args);49va_end(args);5051#if defined(__LIBRETRO__)52if (log_cb)53{54log_cb(RETRO_LOG_INFO, "%s\n", buffer);55return;56}57#endif5859#if defined(DEBUG_GEARCOLECO)60static int count = 1;61printf("%d: %s\n", count, buffer);62count++;63#else64printf("%s\n", buffer);65#endif6667fflush(stdout);68}6970#endif /* LOG_H */717273