1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Make logging defines reusable by Salamander without having to

include general.h (full of dependencies which can't be met for
standalone app)
This commit is contained in:
Twinaphex 2012-07-28 17:32:30 +02:00
parent eef755d525
commit 5da0354257
7 changed files with 137 additions and 57 deletions

View File

@ -7,11 +7,11 @@ include $(CELL_MK_DIR)/sdk.makedef.mk
STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe
PPU_CFLAGS += -I. -D__CELLOS_LV2__
PPU_CFLAGS += -I. -D__CELLOS_LV2__ -DIS_SALAMANDER
PPU_SRCS = console/salamander/main.c file_path.c compat/compat.c conf/config_file.c
ifeq ($(HAVE_LOGGER), 1)
PPU_CFLAGS += -DHAVE_LOGGER
PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger
PPU_SRCS += console/logger/logger.c
endif

View File

@ -31,13 +31,15 @@ OBJ = console/griffin/griffin.o console/font.bmpobj console/rzlib/rzlib.o
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
CFLAGS += -Iconsole/logger
CXXFLAGS += -Iconsole/logger
OBJ += console/logger/logger.o
CFLAGS += -Iconsole/logger
CXXFLAGS += -Iconsole/logger
OBJ += console/logger/logger.o
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
CFLAGS += -Iconsole/logger
CXXFLAGS += -Iconsole/logger
endif
CFLAGS += -std=gnu99 -DHAVE_DEFAULT_RETROPAD_INPUT -DRARCH_CONSOLE -DHAVE_CONFIGFILE=1 -DGEKKO -DHW_RVL -DHAVE_ZLIB -DHAVE_RARCH_MAIN_WRAP -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"0.9.6\" -Dmain=rarch_main -Wno-char-subscripts

View File

@ -18,10 +18,26 @@
#define __RARCH_LOGGER_OVERRIDE_H
#if defined(HAVE_LOGGER)
#include "console/logger/logger.h"
#include "logger.h"
#ifdef IS_SALAMANDER
#define RARCH_LOG(...) do { \
if (g_extern.verbose) logger_send("RetroArch: " __VA_ARGS__); \
logger_send("RetroArch Salamander: " __VA_ARGS__); \
} while(0)
#define RARCH_ERR(...) do { \
logger_send("RetroArch Salamander [ERROR] :: " __VA_ARGS__); \
} while(0)
#define RARCH_WARN(...) do { \
logger_send("RetroArch Salamander [WARN] :: " __VA_ARGS__); \
} while(0)
#else
#define RARCH_LOG(...) do { \
logger_send("RetroArch: " __VA_ARGS__); \
} while(0)
#define RARCH_ERR(...) do { \
@ -31,11 +47,39 @@
#define RARCH_WARN(...) do { \
logger_send("RetroArch [WARN] :: " __VA_ARGS__); \
} while(0)
#endif
#elif defined(HAVE_FILE_LOGGER)
extern FILE * log_fp;
#ifdef IS_SALAMANDER
#ifndef RARCH_LOG
#define RARCH_LOG(...) do { \
fprintf(log_fp, "RetroArch Salamander: " __VA_ARGS__); \
fflush(log_fp); \
} while (0)
#endif
#ifndef RARCH_ERR
#define RARCH_ERR(...) do { \
fprintf(log_fp, "RetroArch Salamander [ERROR] :: " __VA_ARGS__); \
fflush(log_fp); \
} while (0)
#endif
#ifndef RARCH_WARN
#define RARCH_WARN(...) do { \
fprintf(log_fp, "RetroArch Salamander [WARN] :: " __VA_ARGS__); \
fflush(log_fp); \
} while (0)
#endif
#else
#ifndef RARCH_LOG
#define RARCH_LOG(...) do { \
if (g_extern.verbose) \
fprintf(log_fp, "RetroArch: " __VA_ARGS__); \
fflush(log_fp); \
} while (0)
@ -58,3 +102,5 @@ extern FILE * log_fp;
#endif
#endif
#endif

View File

@ -44,28 +44,7 @@
#define PATH_MAX 512
#endif
#ifdef HAVE_LOGGER
#include "logger.h"
#define RARCH_LOG(...) logger_send("RetroArch Salamander: " __VA_ARGS__);
#define RARCH_ERR(...) logger_send("RetroArch Salamander [ERROR] :: " __VA_ARGS__);
#define RARCH_WARN(...) logger_send("RetroArch Salamander [WARN] :: " __VA_ARGS__);
#else
#define RARCH_LOG(...) do { \
fprintf(stderr, "RetroArch Salamander: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#define RARCH_ERR(...) do { \
fprintf(stderr, "RetroArch Salamander [ERROR] :: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#define RARCH_WARN(...) do { \
fprintf(stderr, "RetroArch Salamander [WARN] :: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#endif
#include "../../retroarch_logger.h"
#include "../../file.h"
#if defined(__CELLOS_LV2__)

View File

@ -13,7 +13,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_GENERAL_H
#define __RARCH_GENERAL_H
@ -506,32 +505,7 @@ extern struct console_settings g_console;
#endif
/////////
#if defined(RARCH_CONSOLE) && (defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) || defined(_XBOX1))
#include <logger_override.h>
#else
#ifndef RARCH_LOG
#define RARCH_LOG(...) do { \
if (g_extern.verbose) \
fprintf(stderr, "RetroArch: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#endif
#ifndef RARCH_ERR
#define RARCH_ERR(...) do { \
fprintf(stderr, "RetroArch [ERROR] :: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#endif
#ifndef RARCH_WARN
#define RARCH_WARN(...) do { \
fprintf(stderr, "RetroArch [WARN] :: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#endif
#endif
#include "retroarch_logger.h"
#ifndef max
#define max(a, b) ((a) > (b) ? (a) : (b))

View File

@ -22,7 +22,11 @@
static inline void RARCH_LOG(const char *msg, ...)
{
char msg_new[1024], buffer[1024];
#ifdef IS_SALAMANDER
snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander: %s", msg);
#else
snprintf(msg_new, sizeof(msg_new), "RetroArch: %s", msg);
#endif
va_list ap;
va_start(ap, msg);
wvsprintf(buffer, msg_new, ap);
@ -33,7 +37,11 @@ static inline void RARCH_LOG(const char *msg, ...)
static inline void RARCH_WARN(const char *msg, ...)
{
char msg_new[1024], buffer[1024];
#ifdef IS_SALAMANDER
snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander [WARN] :: %s", msg);
#else
snprintf(msg_new, sizeof(msg_new), "RetroArch [WARN] :: %s", msg);
#endif
va_list ap;
va_start(ap, msg);
wvsprintf(buffer, msg_new, ap);
@ -44,7 +52,11 @@ static inline void RARCH_WARN(const char *msg, ...)
static inline void RARCH_ERR(const char *msg, ...)
{
char msg_new[1024], buffer[1024];
#ifdef IS_SALAMANDER
snprintf(msg_new, sizeof(msg_new), "RetroArch Salamander [ERR] :: %s", msg);
#else
snprintf(msg_new, sizeof(msg_new), "RetroArch [ERR] :: %s", msg);
#endif
va_list ap;
va_start(ap, msg);
wvsprintf(buffer, msg_new, ap);

67
retroarch_logger.h Normal file
View File

@ -0,0 +1,67 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_LOGGER_H
#define __RARCH_LOGGER_H
#if defined(RARCH_CONSOLE) && (defined(HAVE_LOGGER) || defined(HAVE_FILE_LOGGER) || defined(_XBOX1))
#include <logger_override.h>
#else
#ifndef RARCH_LOG
#ifdef IS_SALAMANDER
#define RARCH_LOG(...) do { \
fprintf(stderr, "RetroArch Salamander: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#else
#define RARCH_LOG(...) do { \
fprintf(stderr, "RetroArch: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#endif
#endif
#ifndef RARCH_ERR
#ifdef IS_SALAMANDER
#define RARCH_ERR(...) do { \
fprintf(stderr, "RetroArch Salamander [ERROR] :: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#else
#define RARCH_ERR(...) do { \
fprintf(stderr, "RetroArch [ERROR] :: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#endif
#endif
#ifndef RARCH_WARN
#ifdef IS_SALAMANDER
#define RARCH_WARN(...) do { \
fprintf(stderr, "RetroArch Salamander [WARN] :: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#else
#define RARCH_WARN(...) do { \
fprintf(stderr, "RetroArch [WARN] :: " __VA_ARGS__); \
fflush(stderr); \
} while (0)
#endif
#endif
#endif
#endif