New logging framework stolen from dolphin

This commit is contained in:
Flyinghead 2019-06-30 21:06:46 +02:00
parent ec0d21148d
commit 8404c6322c
26 changed files with 1031 additions and 179 deletions

View File

@ -11,7 +11,7 @@ RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ \
hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/interpr/ hw/sh4/modules/ plugins/ profiler/ oslib/ \
hw/extdev/ hw/arm/ hw/naomi/ imgread/ ./ deps/coreio/ deps/zlib/ deps/chdr/ deps/crypto/ \
deps/libelf/ deps/chdpsr/ arm_emitter/ rend/ reios/ deps/libpng/ deps/xbrz/ \
deps/xxhash/ deps/libzip/ deps/imgui/ archive/ input/
deps/xxhash/ deps/libzip/ deps/imgui/ archive/ input/ log/
ifdef WEBUI
RZDCY_MODULES += webui/

View File

@ -299,31 +299,31 @@ void DYNACALL _vmem_WriteMem64(u32 Address,u64 data) { _vmem_writet<u64>(Address
//default read handlers
u8 DYNACALL _vmem_ReadMem8_not_mapped(u32 addresss)
{
//printf("[sh4]Read8 from 0x%X, not mapped [_vmem default handler]\n",addresss);
DEBUG_LOG(MEMORY, "[sh4]Read8 from 0x%X, not mapped [_vmem default handler]", addresss);
return (u8)MEM_ERROR_RETURN_VALUE;
}
u16 DYNACALL _vmem_ReadMem16_not_mapped(u32 addresss)
{
//printf("[sh4]Read16 from 0x%X, not mapped [_vmem default handler]\n",addresss);
DEBUG_LOG(MEMORY, "[sh4]Read16 from 0x%X, not mapped [_vmem default handler]", addresss);
return (u16)MEM_ERROR_RETURN_VALUE;
}
u32 DYNACALL _vmem_ReadMem32_not_mapped(u32 addresss)
{
//printf("[sh4]Read32 from 0x%X, not mapped [_vmem default handler]\n",addresss);
DEBUG_LOG(MEMORY, "[sh4]Read32 from 0x%X, not mapped [_vmem default handler]", addresss);
return (u32)MEM_ERROR_RETURN_VALUE;
}
//default write handers
void DYNACALL _vmem_WriteMem8_not_mapped(u32 addresss,u8 data)
{
//printf("[sh4]Write8 to 0x%X=0x%X, not mapped [_vmem default handler]\n",addresss,data);
DEBUG_LOG(MEMORY, "[sh4]Write8 to 0x%X=0x%X, not mapped [_vmem default handler]", addresss, data);
}
void DYNACALL _vmem_WriteMem16_not_mapped(u32 addresss,u16 data)
{
//printf("[sh4]Write16 to 0x%X=0x%X, not mapped [_vmem default handler]\n",addresss,data);
DEBUG_LOG(MEMORY, "[sh4]Write16 to 0x%X=0x%X, not mapped [_vmem default handler]", addresss, data);
}
void DYNACALL _vmem_WriteMem32_not_mapped(u32 addresss,u32 data)
{
//printf("[sh4]Write32 to 0x%X=0x%X, not mapped [_vmem default handler]\n",addresss,data);
DEBUG_LOG(MEMORY, "[sh4]Write32 to 0x%X=0x%X, not mapped [_vmem default handler]", addresss, data);
}
//code to register handlers
//0 is considered error :)
@ -522,7 +522,7 @@ bool _vmem_reserve() {
// Fallback to statically allocated buffers, this results in slow-ops being generated.
if (vmemstatus == MemTypeError) {
printf("Warning! nvmem is DISABLED (due to failure or not being built-in\n");
WARN_LOG(VMEM, "Warning! nvmem is DISABLED (due to failure or not being built-in");
virt_ram_base = 0;
// Allocate it all and initialize it.
@ -539,8 +539,8 @@ bool _vmem_reserve() {
aica_ram.data = (u8*)malloc_pages(ARAM_SIZE);
}
else {
printf("Info: nvmem is enabled, with addr space of size %s\n", vmemstatus == MemType4GB ? "4GB" : "512MB");
printf("Info: p_sh4rcb: %p virt_ram_base: %p\n", p_sh4rcb, virt_ram_base);
NOTICE_LOG(VMEM, "Info: nvmem is enabled, with addr space of size %s", vmemstatus == MemType4GB ? "4GB" : "512MB");
INFO_LOG(VMEM, "Info: p_sh4rcb: %p virt_ram_base: %p", p_sh4rcb, virt_ram_base);
// Map the different parts of the memory file into the new memory range we got.
if (vmemstatus == MemType512MB)
{

View File

@ -147,12 +147,12 @@ static void get_udev_events()
{
if (strstr(action, "add") != NULL)
{
//printf("udev monitor: device added %s\n", devnode);
DEBUG_LOG(INPUT, "udev monitor: device added %s", devnode);
input_evdev_add_device(devnode);
}
else if (strstr(action, "remove") != NULL)
{
//printf("udev monitor: device removed %s\n", devnode);
DEBUG_LOG(INPUT, "udev monitor: device removed %s", devnode);
input_evdev_remove_device(devnode);
}
}

View File

@ -13,7 +13,7 @@ public:
if (ioctl(fd, EVIOCGNAME(sizeof(buf) - 1), buf) < 0)
perror("evdev: ioctl(EVIOCGNAME)");
else
printf("evdev: Opened device '%s' ", buf);
INFO_LOG(INPUT, "evdev: Opened device '%s'", buf);
_name = buf;
buf[0] = 0;
if (ioctl(fd, EVIOCGUNIQ(sizeof(buf) - 1), buf) == 0)
@ -50,7 +50,7 @@ public:
#endif
if (find_mapping(mapping_file))
{
printf("using default mapping '%s'\n", input_mapper->name.c_str());
INFO_LOG(INPUT, "using default mapping '%s'", input_mapper->name.c_str());
input_mapper = new InputMapping(*input_mapper);
}
else
@ -59,11 +59,11 @@ public:
save_mapping();
}
else
printf("using custom mapping '%s'\n", input_mapper->name.c_str());
INFO_LOG(INPUT, "using custom mapping '%s'", input_mapper->name.c_str());
}
virtual ~EvdevGamepadDevice() override
{
printf("evdev: Device '%s' on port %d disconnected\n", _name.c_str(), maple_port());
INFO_LOG(INPUT, "evdev: Device '%s' on port %d disconnected", _name.c_str(), maple_port());
close(_fd);
}
@ -138,7 +138,7 @@ protected:
}
axis_min_values[axis] = abs.minimum;
axis_ranges[axis] = abs.maximum - abs.minimum;
//printf("evdev: range of axis %d is from %d to %d\n", axis, axis_min_values[axis], axis_min_values[axis] + axis_ranges[axis]);
DEBUG_LOG(INPUT, "evdev: range of axis %d is from %d to %d", axis, axis_min_values[axis], axis_min_values[axis] + axis_ranges[axis]);
}
private:

View File

@ -12,6 +12,7 @@
#include <sys/time.h>
#include "hw/sh4/dyna/blockmanager.h"
#include "hw/maple/maple_cfg.h"
#include "log/LogManager.h"
#include <unistd.h>
#if defined(TARGET_EMSCRIPTEN)
@ -87,7 +88,7 @@ void os_SetupInput()
#if defined(USE_JOYSTICK)
int joystick_device_id = cfgLoadInt("input", "joystick_device_id", JOYSTICK_DEFAULT_DEVICE_ID);
if (joystick_device_id < 0) {
puts("Legacy Joystick input disabled by config.\n");
INFO_LOG(INPUT, "Legacy Joystick input disabled by config.");
}
else
{
@ -342,6 +343,7 @@ std::vector<string> find_system_data_dirs()
int main(int argc, wchar* argv[])
{
LogManager::Init();
#ifdef TARGET_PANDORA
signal(SIGSEGV, clean_exit);
signal(SIGKILL, clean_exit);
@ -361,8 +363,8 @@ int main(int argc, wchar* argv[])
{
add_system_data_dir(dirs[i]);
}
printf("Config dir is: %s\n", get_writable_config_path("/").c_str());
printf("Data dir is: %s\n", get_writable_data_path("/").c_str());
INFO_LOG(BOOT, "Config dir is: %s", get_writable_config_path("/").c_str());
INFO_LOG(BOOT, "Data dir is: %s", get_writable_data_path("/").c_str());
#if defined(USE_SDL)
if (SDL_Init(0) != 0)

View File

@ -107,7 +107,7 @@ void x11_window_set_fullscreen(bool fullscreen)
xev.xclient.data.l[3] = 1;
xev.xclient.data.l[4] = 0;
printf("x11: setting fullscreen to %d\n", fullscreen);
INFO_LOG(RENDERER, "x11: setting fullscreen to %d", fullscreen);
XSendEvent((Display*)x11_disp, DefaultRootWindow((Display*)x11_disp), False, SubstructureNotifyMask, &xev);
}
@ -261,9 +261,9 @@ void input_x11_handle()
if (e.type == KeyRelease && e.xkey.keycode == KEY_F10)
{
if (sample_Switch(3000)) {
printf("Starting profiling\n");
INFO_LOG(COMMON, "Starting profiling");
} else {
printf("Stopping profiling\n");
INFO_LOG(COMMON, "Stopping profiling");
}
}
else
@ -358,7 +358,7 @@ void input_x11_init()
x11_keyboard_input = (cfgLoadInt("input", "enable_x11_keyboard", 1) >= 1);
if (!x11_keyboard_input)
printf("X11 Keyboard input disabled by config.\n");
INFO_LOG(INPUT, "X11 Keyboard input disabled by config.");
}
static int x11_error_handler(Display *, XErrorEvent *)
@ -390,7 +390,7 @@ void x11_window_create()
x11Display = XOpenDisplay(NULL);
if (!x11Display && !(x11Display = XOpenDisplay(":0")))
{
printf("Error: Unable to open X display\n");
ERROR_LOG(RENDERER, "Error: Unable to open X display");
return;
}
x11Screen = XDefaultScreen(x11Display);
@ -437,17 +437,17 @@ void x11_window_create()
GLXFBConfig* fbc = glXChooseFBConfig(x11Display, x11Screen, visual_attribs, &fbcount);
if (!fbc)
{
printf("Failed to retrieve a framebuffer config\n");
ERROR_LOG(RENDERER, "Failed to retrieve a framebuffer config");
exit(1);
}
printf("Found %d matching FB configs.\n", fbcount);
INFO_LOG(RENDERER, "Found %d matching FB configs.", fbcount);
GLXFBConfig bestFbc = fbc[0];
XFree(fbc);
// Get a visual
XVisualInfo *vi = glXGetVisualFromFBConfig(x11Display, bestFbc);
printf("Chosen visual ID = 0x%lx\n", vi->visualid);
INFO_LOG(RENDERER, "Chosen visual ID = 0x%lx", vi->visualid);
depth = vi->depth;
@ -460,7 +460,7 @@ void x11_window_create()
XMatchVisualInfo(x11Display, x11Screen, i32Depth, TrueColor, x11Visual);
if (!x11Visual)
{
printf("Error: Unable to acquire visual\n");
ERROR_LOG(RENDERER, "Error: Unable to acquire visual");
return;
}
x11Colormap = XCreateColormap(x11Display, sRootWindow, x11Visual->visual, AllocNone);
@ -529,7 +529,7 @@ void x11_window_create()
x11_glc = glXCreateContextAttribsARB(x11Display, bestFbc, 0, True, context_attribs);
if (!x11_glc)
{
printf("Open GL 4.3 not supported\n");
INFO_LOG(RENDERER, "Open GL 4.3 not supported");
// Try GL 3.0
context_attribs[1] = 3;
context_attribs[3] = 0;
@ -555,7 +555,7 @@ void x11_window_create()
}
else
{
printf("Not creating X11 window ..\n");
INFO_LOG(RENDERER, "Not creating X11 window ..");
}
}

View File

@ -45,7 +45,7 @@ void sigill_handler(int sn, siginfo_t * si, void *segfault_ctx) {
unat pc = (unat)ctx.pc;
bool dyna_cde = (pc>(unat)CodeCache) && (pc<(unat)(CodeCache + CODE_SIZE + TEMP_CODE_SIZE));
printf("SIGILL @ %lx -> %p was not in vram, dynacode:%d\n", pc, si->si_addr, dyna_cde);
ERROR_LOG(COMMON, "SIGILL @ %lx -> %p was not in vram, dynacode:%d", pc, si->si_addr, dyna_cde);
//printf("PC is used here %08X\n", pc);
kill(getpid(), SIGABRT);
@ -109,7 +109,7 @@ void fault_handler (int sn, siginfo_t * si, void *segfault_ctx)
#endif
else
{
printf("SIGSEGV @ %lx -> %p was not in vram, dynacode:%d\n", ctx.pc, si->si_addr, dyna_cde);
ERROR_LOG(COMMON, "SIGSEGV @ %lx -> %p was not in vram, dynacode:%d", ctx.pc, si->si_addr, dyna_cde);
die("segfault");
signal(SIGSEGV, SIG_DFL);
}
@ -172,15 +172,15 @@ void enable_runfast()
: "r"(x), "r"(y)
);
printf("ARM VFP-Run Fast (NFP) enabled !\n");
DEBUG_LOG(BOOT, "ARM VFP-Run Fast (NFP) enabled !");
#endif
}
void linux_fix_personality() {
#if !defined(TARGET_BSD) && !defined(_ANDROID) && !defined(TARGET_OS_MAC) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN)
printf("Personality: %08X\n", personality(0xFFFFFFFF));
DEBUG_LOG(BOOT, "Personality: %08X", personality(0xFFFFFFFF));
personality(~READ_IMPLIES_EXEC & personality(0xFFFFFFFF));
printf("Updated personality: %08X\n", personality(0xFFFFFFFF));
DEBUG_LOG(BOOT, "Updated personality: %08X", personality(0xFFFFFFFF));
#endif
}
@ -192,10 +192,10 @@ void linux_rpi2_init() {
handle = dlopen("libbcm_host.so", RTLD_LAZY);
if (handle) {
printf("found libbcm_host\n");
DEBUG_LOG(BOOT, "found libbcm_host");
*(void**) (&rpi_bcm_init) = dlsym(handle, "bcm_host_init");
if (rpi_bcm_init) {
printf("rpi2: bcm_init\n");
DEBUG_LOG(BOOT, "rpi2: bcm_init");
rpi_bcm_init();
}
}
@ -213,7 +213,7 @@ void common_linux_setup()
settings.profile.run_counts=0;
printf("Linux paging: %ld %08X %08X\n",sysconf(_SC_PAGESIZE),PAGE_SIZE,PAGE_MASK);
DEBUG_LOG(BOOT, "Linux paging: %ld %08X %08X", sysconf(_SC_PAGESIZE), PAGE_SIZE, PAGE_MASK);
verify(PAGE_MASK==(sysconf(_SC_PAGESIZE)-1));
}
#endif

View File

@ -275,7 +275,7 @@ bool vmem_platform_prepare_jit_block(void *code_area, unsigned size, void **code
*code_area_rw = ptr_rw;
*rx_offset = (char*)ptr_rx - (char*)ptr_rw;
printf("Info: Using NO_RWX mode, rx ptr: %p, rw ptr: %p, offset: %lu\n", ptr_rx, ptr_rw, (unsigned long)*rx_offset);
INFO_LOG(DYNAREC, "Info: Using NO_RWX mode, rx ptr: %p, rw ptr: %p, offset: %lu", ptr_rx, ptr_rw, (unsigned long)*rx_offset);
return (ptr_rw != MAP_FAILED);
}

218
core/log/BitSet.h Normal file
View File

@ -0,0 +1,218 @@
// This file is under the public domain.
#pragma once
#include <cstddef>
#include <initializer_list>
#include <type_traits>
#include "types.h"
#ifdef _WIN32
#include <intrin.h>
namespace Common
{
template <typename T>
constexpr int CountSetBits(T v)
{
// from https://graphics.stanford.edu/~seander/bithacks.html
// GCC has this built in, but MSVC's intrinsic will only emit the actual
// POPCNT instruction, which we're not depending on
v = v - ((v >> 1) & (T) ~(T)0 / 3);
v = (v & (T) ~(T)0 / 15 * 3) + ((v >> 2) & (T) ~(T)0 / 15 * 3);
v = (v + (v >> 4)) & (T) ~(T)0 / 255 * 15;
return (T)(v * ((T) ~(T)0 / 255)) >> (sizeof(T) - 1) * 8;
}
inline int LeastSignificantSetBit(u8 val)
{
unsigned long index;
_BitScanForward(&index, val);
return (int)index;
}
inline int LeastSignificantSetBit(u16 val)
{
unsigned long index;
_BitScanForward(&index, val);
return (int)index;
}
inline int LeastSignificantSetBit(u32 val)
{
unsigned long index;
_BitScanForward(&index, val);
return (int)index;
}
inline int LeastSignificantSetBit(u64 val)
{
unsigned long index;
_BitScanForward64(&index, val);
return (int)index;
}
#else
namespace Common
{
constexpr int CountSetBits(u8 val)
{
return __builtin_popcount(val);
}
constexpr int CountSetBits(u16 val)
{
return __builtin_popcount(val);
}
constexpr int CountSetBits(u32 val)
{
return __builtin_popcount(val);
}
constexpr int CountSetBits(u64 val)
{
return __builtin_popcountll(val);
}
inline int LeastSignificantSetBit(u8 val)
{
return __builtin_ctz(val);
}
inline int LeastSignificantSetBit(u16 val)
{
return __builtin_ctz(val);
}
inline int LeastSignificantSetBit(u32 val)
{
return __builtin_ctz(val);
}
inline int LeastSignificantSetBit(u64 val)
{
return __builtin_ctzll(val);
}
#endif
// Similar to std::bitset, this is a class which encapsulates a bitset, i.e.
// using the set bits of an integer to represent a set of integers. Like that
// class, it acts like an array of bools:
// BitSet32 bs;
// bs[1] = true;
// but also like the underlying integer ([0] = least significant bit):
// BitSet32 bs2 = ...;
// bs = (bs ^ bs2) & BitSet32(0xffff);
// The following additional functionality is provided:
// - Construction using an initializer list.
// BitSet bs { 1, 2, 4, 8 };
// - Efficiently iterating through the set bits:
// for (int i : bs)
// [i is the *index* of a set bit]
// (This uses the appropriate CPU instruction to find the next set bit in one
// operation.)
// - Counting set bits using .Count() - see comment on that method.
// TODO: use constexpr when MSVC gets out of the Dark Ages
template <typename IntTy>
class BitSet
{
static_assert(!std::is_signed<IntTy>::value, "BitSet should not be used with signed types");
public:
// A reference to a particular bit, returned from operator[].
class Ref
{
public:
constexpr Ref(Ref&& other) : m_bs(other.m_bs), m_mask(other.m_mask) {}
constexpr Ref(BitSet* bs, IntTy mask) : m_bs(bs), m_mask(mask) {}
constexpr operator bool() const { return (m_bs->m_val & m_mask) != 0; }
bool operator=(bool set)
{
m_bs->m_val = (m_bs->m_val & ~m_mask) | (set ? m_mask : 0);
return set;
}
private:
BitSet* m_bs;
IntTy m_mask;
};
// A STL-like iterator is required to be able to use range-based for loops.
class Iterator
{
public:
constexpr Iterator(const Iterator& other) : m_val(other.m_val), m_bit(other.m_bit) {}
constexpr Iterator(IntTy val, int bit) : m_val(val), m_bit(bit) {}
Iterator& operator=(Iterator other)
{
new (this) Iterator(other);
return *this;
}
Iterator& operator++()
{
if (m_val == 0)
{
m_bit = -1;
}
else
{
int bit = LeastSignificantSetBit(m_val);
m_val &= ~(1 << bit);
m_bit = bit;
}
return *this;
}
Iterator operator++(int)
{
Iterator other(*this);
++*this;
return other;
}
constexpr int operator*() const { return m_bit; }
constexpr bool operator==(Iterator other) const { return m_bit == other.m_bit; }
constexpr bool operator!=(Iterator other) const { return m_bit != other.m_bit; }
private:
IntTy m_val;
int m_bit;
};
constexpr BitSet() : m_val(0) {}
constexpr explicit BitSet(IntTy val) : m_val(val) {}
BitSet(std::initializer_list<int> init)
{
m_val = 0;
for (int bit : init)
m_val |= (IntTy)1 << bit;
}
constexpr static BitSet AllTrue(size_t count)
{
return BitSet(count == sizeof(IntTy) * 8 ? ~(IntTy)0 : (((IntTy)1 << count) - 1));
}
Ref operator[](size_t bit) { return Ref(this, (IntTy)1 << bit); }
constexpr const Ref operator[](size_t bit) const { return (*const_cast<BitSet*>(this))[bit]; }
constexpr bool operator==(BitSet other) const { return m_val == other.m_val; }
constexpr bool operator!=(BitSet other) const { return m_val != other.m_val; }
constexpr bool operator<(BitSet other) const { return m_val < other.m_val; }
constexpr bool operator>(BitSet other) const { return m_val > other.m_val; }
constexpr BitSet operator|(BitSet other) const { return BitSet(m_val | other.m_val); }
constexpr BitSet operator&(BitSet other) const { return BitSet(m_val & other.m_val); }
constexpr BitSet operator^(BitSet other) const { return BitSet(m_val ^ other.m_val); }
constexpr BitSet operator~() const { return BitSet(~m_val); }
constexpr BitSet operator<<(IntTy shift) const { return BitSet(m_val << shift); }
constexpr BitSet operator>>(IntTy shift) const { return BitSet(m_val >> shift); }
constexpr explicit operator bool() const { return m_val != 0; }
BitSet& operator|=(BitSet other) { return *this = *this | other; }
BitSet& operator&=(BitSet other) { return *this = *this & other; }
BitSet& operator^=(BitSet other) { return *this = *this ^ other; }
BitSet& operator<<=(IntTy shift) { return *this = *this << shift; }
BitSet& operator>>=(IntTy shift) { return *this = *this >> shift; }
// Warning: Even though on modern CPUs this is a single fast instruction,
// Dolphin's official builds do not currently assume POPCNT support on x86,
// so slower explicit bit twiddling is generated. Still should generally
// be faster than a loop.
constexpr unsigned int Count() const { return CountSetBits(m_val); }
constexpr Iterator begin() const { return ++Iterator(m_val, 0); }
constexpr Iterator end() const { return Iterator(m_val, -1); }
IntTy m_val;
};
} // namespace Common
using BitSet8 = Common::BitSet<u8>;
using BitSet16 = Common::BitSet<u16>;
using BitSet32 = Common::BitSet<u32>;
using BitSet64 = Common::BitSet<u64>;

View File

@ -0,0 +1,19 @@
// Copyright 2010 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "LogManager.h"
class ConsoleListener : public LogListener
{
public:
ConsoleListener();
~ConsoleListener();
void Log(LogTypes::LOG_LEVELS, const char* text) override;
private:
bool m_use_color;
};

View File

@ -0,0 +1,46 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#ifdef _ANDROID
#include <android/log.h>
#include "types.h"
#include "ConsoleListener.h"
ConsoleListener::ConsoleListener()
{
}
ConsoleListener::~ConsoleListener()
{
}
void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
{
android_LogPriority logLevel = ANDROID_LOG_UNKNOWN;
// Map dolphin's log levels to android's
switch (level)
{
case LogTypes::LOG_LEVELS::LDEBUG:
logLevel = ANDROID_LOG_DEBUG;
break;
case LogTypes::LOG_LEVELS::LINFO:
logLevel = ANDROID_LOG_INFO;
break;
case LogTypes::LOG_LEVELS::LWARNING:
logLevel = ANDROID_LOG_WARN;
break;
case LogTypes::LOG_LEVELS::LERROR:
logLevel = ANDROID_LOG_ERROR;
break;
case LogTypes::LOG_LEVELS::LNOTICE:
logLevel = ANDROID_LOG_INFO;
break;
}
__android_log_write(logLevel, LOG_TAG, text);
}
#endif // _ANDROID

View File

@ -0,0 +1,53 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#if !defined(_WIN32) && !defined(_ANDROID)
#include <cstdio>
#include <cstring>
#ifndef _WIN32
#include <unistd.h>
#endif
#include "ConsoleListener.h"
#include "Log.h"
ConsoleListener::ConsoleListener()
{
m_use_color = !!isatty(fileno(stdout));
}
ConsoleListener::~ConsoleListener()
{
fflush(nullptr);
}
void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
{
char color_attr[16] = "";
char reset_attr[16] = "";
if (m_use_color)
{
strcpy(reset_attr, "\x1b[0m");
switch (level)
{
case LogTypes::LOG_LEVELS::LNOTICE:
// light green
strcpy(color_attr, "\x1b[92m");
break;
case LogTypes::LOG_LEVELS::LERROR:
// light red
strcpy(color_attr, "\x1b[91m");
break;
case LogTypes::LOG_LEVELS::LWARNING:
// light yellow
strcpy(color_attr, "\x1b[93m");
break;
default:
break;
}
}
fprintf(stderr, "%s%s%s", color_attr, text, reset_attr);
}
#endif // !_WIN32 && !_ANDROID

View File

@ -0,0 +1,23 @@
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#ifdef _WIN32
#include <windows.h>
#include "ConsoleListener.h"
ConsoleListener::ConsoleListener()
{
}
ConsoleListener::~ConsoleListener()
{
}
void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
{
::OutputDebugStringA(text);
}
#endif // _WIN32

95
core/log/Log.h Normal file
View File

@ -0,0 +1,95 @@
// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
namespace LogTypes
{
enum LOG_TYPE
{
AICA,
AICA_ARM,
AUDIO,
BOOT,
COMMON,
DYNAREC,
FLASHROM,
GDROM,
HOLLY,
INPUT,
JVS,
MAPLE,
INTERPRETER,
MEMORY,
VMEM,
MODEM,
NAOMI,
PVR,
RENDERER,
SAVESTATE,
NUMBER_OF_LOGS // Must be last
};
enum LOG_LEVELS
{
LNOTICE = 1, // VERY important information that is NOT errors. Like startup and OSReports.
LERROR = 2, // Critical errors
LWARNING = 3, // Something is suspicious.
LINFO = 4, // General information.
LDEBUG = 5, // Detailed debugging - might make things slow.
};
static const char LOG_LEVEL_TO_CHAR[7] = "-NEWID";
} // namespace LogTypes
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
const char* fmt, ...)
#ifdef __GNUC__
__attribute__((format(printf, 5, 6)))
#endif
;
#if !defined(RELEASE) || defined(DEBUGFAST)
#define MAX_LOGLEVEL LogTypes::LOG_LEVELS::LDEBUG
#else
#ifndef MAX_LOGLEVEL
#define MAX_LOGLEVEL LogTypes::LOG_LEVELS::LINFO
#endif // loglevel
#endif // logging
// Let the compiler optimize this out
#define GENERIC_LOG(t, v, ...) \
do \
{ \
if (v <= MAX_LOGLEVEL) \
GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
} while (0)
#define ERROR_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__); \
} while (0)
#define WARN_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__); \
} while (0)
#define NOTICE_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__); \
} while (0)
#define INFO_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__); \
} while (0)
#define DEBUG_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__); \
} while (0)

244
core/log/LogManager.cpp Normal file
View File

@ -0,0 +1,244 @@
// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "LogManager.h"
#include <algorithm>
#include <cstdarg>
#include <cstring>
#include <locale>
#include <mutex>
#include <ostream>
#include <string>
#include <fstream>
#include "ConsoleListener.h"
#include "Log.h"
#include "StringUtil.h"
#include "cfg/cfg.h"
#include "oslib/oslib.h"
constexpr size_t MAX_MSGLEN = 1024;
template <typename T>
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
{
#ifdef _WIN32
fstream.open(UTF8ToTStr(filename).c_str(), openmode);
#else
fstream.open(filename.c_str(), openmode);
#endif
}
class FileLogListener : public LogListener
{
public:
FileLogListener(const std::string& filename)
{
OpenFStream(m_logfile, filename, std::ios::app);
SetEnable(true);
}
void Log(LogTypes::LOG_LEVELS, const char* msg) override
{
if (!IsEnabled() || !IsValid())
return;
std::lock_guard<std::mutex> lk(m_log_lock);
m_logfile << msg << std::flush;
}
bool IsValid() const { return m_logfile.good(); }
bool IsEnabled() const { return m_enable; }
void SetEnable(bool enable) { m_enable = enable; }
private:
std::mutex m_log_lock;
std::ofstream m_logfile;
bool m_enable;
};
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
if (LogManager::GetInstance())
LogManager::GetInstance()->Log(level, type, file, line, fmt, args);
va_end(args);
}
static size_t DeterminePathCutOffPoint()
{
constexpr const char* pattern = "/core/";
#ifdef _WIN32
constexpr const char* pattern2 = "\\core\\";
#endif
std::string path = __FILE__;
std::transform(path.begin(), path.end(), path.begin(),
[](char c) { return std::tolower(c, std::locale::classic()); });
size_t pos = path.find(pattern);
#ifdef _WIN32
if (pos == std::string::npos)
pos = path.find(pattern2);
#endif
if (pos != std::string::npos)
return pos + strlen(pattern);
return 0;
}
LogManager::LogManager()
{
// create log containers
m_log[LogTypes::AICA] = {"AICA", "AICA Audio Emulation"};
m_log[LogTypes::AICA_ARM] = {"AICA_ARM", "AICA ARM Emulation"};
m_log[LogTypes::AUDIO] = {"Audio", "Audio Ouput Interface"};
m_log[LogTypes::BOOT] = {"BOOT", "Boot"};
m_log[LogTypes::COMMON] = {"COMMON", "Common"};
m_log[LogTypes::DYNAREC] = {"DYNAREC", "Dynamic Recompiler"};
m_log[LogTypes::FLASHROM] = {"FLASHROM", "FlashROM / EEPROM"};
m_log[LogTypes::GDROM] = {"GDROM", "GD-Rom Drive"};
m_log[LogTypes::HOLLY] = {"HOLLY", "Holly Chipset"};
m_log[LogTypes::INPUT] = {"INPUT", "Input Peripherals"};
m_log[LogTypes::JVS] = {"JVS", "Naomi JVS Protocol"};
m_log[LogTypes::MAPLE] = {"MAPLE", "Maple Bus and Peripherals"};
m_log[LogTypes::INTERPRETER] = {"INTERPRETER", "SH4 Interpreter"};
m_log[LogTypes::MEMORY] = {"MEMORY", "Memory Management"};
m_log[LogTypes::VMEM] = {"VMEM", "Virtual Memory Management"};
m_log[LogTypes::MODEM] = {"MODEM", "Modem and Network"};
m_log[LogTypes::NAOMI] = {"NAOMI", "Naomi"};
m_log[LogTypes::PVR] = {"PVR", "PowerVR GPU"};
m_log[LogTypes::RENDERER] = {"RENDERER", "OpenGL Renderer"};
m_log[LogTypes::SAVESTATE] = {"SAVESTATE", "Save States"};
RegisterListener(LogListener::FILE_LISTENER, new FileLogListener("flycast.log"));
RegisterListener(LogListener::CONSOLE_LISTENER, new ConsoleListener());
// Set up log listeners
int verbosity = cfgLoadInt("log", "Verbosity", LogTypes::LDEBUG);
// Ensure the verbosity level is valid
if (verbosity < 1)
verbosity = 1;
if (verbosity > MAX_LOGLEVEL)
verbosity = MAX_LOGLEVEL;
SetLogLevel(static_cast<LogTypes::LOG_LEVELS>(verbosity));
EnableListener(LogListener::FILE_LISTENER, cfgLoadBool("log", "LogToFile", false));
EnableListener(LogListener::CONSOLE_LISTENER, cfgLoadBool("log", "LogToConsole", true));
// EnableListener(LogListener::LOG_WINDOW_LISTENER, Config::Get(LOGGER_WRITE_TO_WINDOW));
for (LogContainer& container : m_log)
{
container.m_enable = cfgLoadBool("log", container.m_short_name, true);
}
m_path_cutoff_point = DeterminePathCutOffPoint();
}
LogManager::~LogManager()
{
// The log window listener pointer is owned by the GUI code.
delete m_listeners[LogListener::CONSOLE_LISTENER];
delete m_listeners[LogListener::FILE_LISTENER];
}
// Return the current time formatted as Minutes:Seconds:Milliseconds
// in the form 00:00:000.
static std::string GetTimeFormatted()
{
double now = os_GetSeconds();
u32 minutes = (u32)now / 60;
u32 seconds = (u32)now % 60;
u32 ms = (now - (u32)now) * 1000;
return StringFromFormat("%02d:%02d:%03d", minutes, seconds, ms);
}
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file,
int line, const char* format, va_list args)
{
return LogWithFullPath(level, type, file + m_path_cutoff_point, line, format, args);
}
void LogManager::LogWithFullPath(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
const char* file, int line, const char* format, va_list args)
{
if (!IsEnabled(type, level) || !static_cast<bool>(m_listener_ids))
return;
char temp[MAX_MSGLEN];
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);
std::string msg =
StringFromFormat("%s %s:%u %c[%s]: %s\n", GetTimeFormatted().c_str(), file,
line, LogTypes::LOG_LEVEL_TO_CHAR[(int)level], GetShortName(type), temp);
for (auto listener_id : m_listener_ids)
if (m_listeners[listener_id])
m_listeners[listener_id]->Log(level, msg.c_str());
}
LogTypes::LOG_LEVELS LogManager::GetLogLevel() const
{
return m_level;
}
void LogManager::SetLogLevel(LogTypes::LOG_LEVELS level)
{
m_level = level;
}
void LogManager::SetEnable(LogTypes::LOG_TYPE type, bool enable)
{
m_log[type].m_enable = enable;
}
bool LogManager::IsEnabled(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) const
{
return m_log[type].m_enable && GetLogLevel() >= level;
}
const char* LogManager::GetShortName(LogTypes::LOG_TYPE type) const
{
return m_log[type].m_short_name;
}
const char* LogManager::GetFullName(LogTypes::LOG_TYPE type) const
{
return m_log[type].m_full_name;
}
void LogManager::RegisterListener(LogListener::LISTENER id, LogListener* listener)
{
m_listeners[id] = listener;
}
void LogManager::EnableListener(LogListener::LISTENER id, bool enable)
{
m_listener_ids[id] = enable;
}
bool LogManager::IsListenerEnabled(LogListener::LISTENER id) const
{
return m_listener_ids[id];
}
// Singleton. Ugh.
static LogManager* s_log_manager;
LogManager* LogManager::GetInstance()
{
return s_log_manager;
}
void LogManager::Init()
{
s_log_manager = new LogManager();
}
void LogManager::Shutdown()
{
delete s_log_manager;
s_log_manager = nullptr;
}

80
core/log/LogManager.h Normal file
View File

@ -0,0 +1,80 @@
// Copyright 2009 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <array>
#include <cstdarg>
#include "BitSet.h"
#include "Log.h"
// pure virtual interface
class LogListener
{
public:
virtual ~LogListener() {}
virtual void Log(LogTypes::LOG_LEVELS, const char* msg) = 0;
enum LISTENER
{
FILE_LISTENER = 0,
CONSOLE_LISTENER,
LOG_WINDOW_LISTENER,
NUMBER_OF_LISTENERS // Must be last
};
};
class LogManager
{
public:
static LogManager* GetInstance();
static void Init();
static void Shutdown();
void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
const char* fmt, va_list args);
void LogWithFullPath(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file,
int line, const char* fmt, va_list args);
LogTypes::LOG_LEVELS GetLogLevel() const;
void SetLogLevel(LogTypes::LOG_LEVELS level);
void SetEnable(LogTypes::LOG_TYPE type, bool enable);
bool IsEnabled(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level = LogTypes::LNOTICE) const;
const char* GetShortName(LogTypes::LOG_TYPE type) const;
const char* GetFullName(LogTypes::LOG_TYPE type) const;
void RegisterListener(LogListener::LISTENER id, LogListener* listener);
void EnableListener(LogListener::LISTENER id, bool enable);
bool IsListenerEnabled(LogListener::LISTENER id) const;
private:
struct LogContainer
{
LogContainer() : m_short_name(NULL), m_full_name(NULL) {}
LogContainer(const char* shortName, const char* fullName, bool enable = false)
: m_short_name(shortName), m_full_name(fullName), m_enable(enable)
{}
const char* m_short_name;
const char* m_full_name;
bool m_enable = false;
};
LogManager();
~LogManager();
LogManager(const LogManager&) = delete;
LogManager& operator=(const LogManager&) = delete;
LogManager(LogManager&&) = delete;
LogManager& operator=(LogManager&&) = delete;
LogTypes::LOG_LEVELS m_level;
std::array<LogContainer, LogTypes::NUMBER_OF_LOGS> m_log{};
std::array<LogListener*, LogListener::NUMBER_OF_LISTENERS> m_listeners{};
BitSet32 m_listener_ids;
size_t m_path_cutoff_point = 0;
};

113
core/log/StringUtil.h Normal file
View File

@ -0,0 +1,113 @@
#include <locale>
#ifdef _WIN32
#include <Windows.h>
constexpr u32 CODEPAGE_SHIFT_JIS = 932;
constexpr u32 CODEPAGE_WINDOWS_1252 = 1252;
#else
#include <codecvt>
#include <errno.h>
#include <iconv.h>
#include <locale.h>
#endif
#if !defined(_WIN32) && !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
static locale_t GetCLocale()
{
static locale_t c_locale = newlocale(LC_ALL_MASK, "C", nullptr);
return c_locale;
}
#endif
bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args)
{
int writtenCount;
#ifdef _WIN32
// You would think *printf are simple, right? Iterate on each character,
// if it's a format specifier handle it properly, etc.
//
// Nooooo. Not according to the C standard.
//
// According to the C99 standard (7.19.6.1 "The fprintf function")
// The format shall be a multibyte character sequence
//
// Because some character encodings might have '%' signs in the middle of
// a multibyte sequence (SJIS for example only specifies that the first
// byte of a 2 byte sequence is "high", the second byte can be anything),
// printf functions have to decode the multibyte sequences and try their
// best to not screw up.
//
// Unfortunately, on Windows, the locale for most languages is not UTF-8
// as we would need. Notably, for zh_TW, Windows chooses EUC-CN as the
// locale, and completely fails when trying to decode UTF-8 as EUC-CN.
//
// On the other hand, the fix is simple: because we use UTF-8, no such
// multibyte handling is required as we can simply assume that no '%' char
// will be present in the middle of a multibyte sequence.
//
// This is why we look up the default C locale here and use _vsnprintf_l.
static _locale_t c_locale = nullptr;
if (!c_locale)
c_locale = _create_locale(LC_ALL, "C");
writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args);
#else
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
locale_t previousLocale = uselocale(GetCLocale());
#endif
writtenCount = vsnprintf(out, outsize, format, args);
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
uselocale(previousLocale);
#endif
#endif
if (writtenCount > 0 && writtenCount < outsize)
{
out[writtenCount] = '\0';
return true;
}
else
{
out[outsize - 1] = '\0';
return false;
}
}
std::string StringFromFormatV(const char* format, va_list args)
{
char* buf = nullptr;
#ifdef _WIN32
int required = _vscprintf(format, args);
buf = new char[required + 1];
CharArrayFromFormatV(buf, required + 1, format, args);
std::string temp = buf;
delete[] buf;
#else
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
locale_t previousLocale = uselocale(GetCLocale());
#endif
if (vasprintf(&buf, format, args) < 0)
{
ERROR_LOG(COMMON, "Unable to allocate memory for string");
buf = nullptr;
}
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
uselocale(previousLocale);
#endif
std::string temp = buf;
free(buf);
#endif
return temp;
}
std::string StringFromFormat(const char* format, ...)
{
va_list args;
va_start(args, format);
std::string res = StringFromFormatV(format, args);
va_end(args);
return res;
}

View File

@ -24,6 +24,7 @@
#include "profiler/profiler.h"
#include "input/gamepad_device.h"
#include "hw/sh4/dyna/blockmanager.h"
#include "log/LogManager.h"
void FlushCache();
void LoadCustom();
@ -132,7 +133,7 @@ void plugins_Reset(bool Manual)
void LoadSpecialSettings()
{
#if DC_PLATFORM == DC_PLATFORM_DREAMCAST
printf("Game ID is [%s]\n", reios_product_number);
INFO_LOG(BOOT, "Game ID is [%s]", reios_product_number);
rtt_to_buffer_game = false;
safemode_game = false;
tr_poly_depth_mask_game = false;
@ -142,7 +143,7 @@ void LoadSpecialSettings()
if (reios_windows_ce)
{
printf("Enabling Full MMU and Extra depth scaling for Windows CE game\n");
INFO_LOG(BOOT, "Enabling Full MMU and Extra depth scaling for Windows CE game\n");
settings.rend.ExtraDepthScale = 0.1;
extra_depth_game = true;
settings.dreamcast.FullMMU = true;
@ -187,14 +188,14 @@ void LoadSpecialSettings()
// Ducati World (PAL)
|| !strncmp("T-8121D-50", reios_product_number, 10))
{
printf("Enabling Dynarec safe mode for game %s\n", reios_product_number);
INFO_LOG(BOOT, "Enabling Dynarec safe mode for game %s\n", reios_product_number);
settings.dynarec.safemode = 1;
safemode_game = true;
}
// NHL 2K2
if (!strncmp("MK-51182", reios_product_number, 8))
{
printf("Enabling Extra depth scaling for game %s\n", reios_product_number);
INFO_LOG(BOOT, "Enabling Extra depth scaling for game %s\n", reios_product_number);
settings.rend.ExtraDepthScale = 10000;
extra_depth_game = true;
}
@ -217,22 +218,22 @@ void LoadSpecialSettings()
// Marionette Company 2
|| !strncmp("T5203M", reios_product_number, 6))
{
printf("Disabling 32-bit virtual memory for game %s\n", reios_product_number);
INFO_LOG(BOOT, "Disabling 32-bit virtual memory for game %s\n", reios_product_number);
settings.dynarec.disable_vmem32 = true;
disable_vmem32_game = true;
}
#elif DC_PLATFORM == DC_PLATFORM_NAOMI || DC_PLATFORM == DC_PLATFORM_ATOMISWAVE
printf("Game ID is [%s]\n", naomi_game_id);
INFO_LOG(BOOT, "Game ID is [%s]", naomi_game_id);
if (!strcmp("METAL SLUG 6", naomi_game_id) || !strcmp("WAVE RUNNER GP", naomi_game_id))
{
printf("Enabling Dynarec safe mode for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling Dynarec safe mode for game %s", naomi_game_id);
settings.dynarec.safemode = 1;
safemode_game = true;
}
if (!strcmp("SAMURAI SPIRITS 6", naomi_game_id))
{
printf("Enabling Extra depth scaling for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling Extra depth scaling for game %s", naomi_game_id);
settings.rend.ExtraDepthScale = 1e26;
extra_depth_game = true;
}
@ -243,41 +244,41 @@ void LoadSpecialSettings()
|| !strcmp("CRACKIN'DJ PART2 ver JAPAN", naomi_game_id)
|| !strcmp("KICK '4' CASH", naomi_game_id))
{
printf("Enabling JVS rotary encoders for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling JVS rotary encoders for game %s", naomi_game_id);
settings.input.JammaSetup = 2;
}
else if (!strcmp("POWER STONE 2 JAPAN", naomi_game_id) // Naomi
|| !strcmp("GUILTY GEAR isuka", naomi_game_id)) // AW
{
printf("Enabling 4-player setup for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling 4-player setup for game %s", naomi_game_id);
settings.input.JammaSetup = 1;
}
else if (!strcmp("SEGA MARINE FISHING JAPAN", naomi_game_id)
|| !strcmp(naomi_game_id, "BASS FISHING SIMULATOR VER.A")) // AW
{
printf("Enabling specific JVS setup for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling specific JVS setup for game %s", naomi_game_id);
settings.input.JammaSetup = 3;
}
else if (!strcmp("RINGOUT 4X4 JAPAN", naomi_game_id))
{
printf("Enabling specific JVS setup for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling specific JVS setup for game %s", naomi_game_id);
settings.input.JammaSetup = 4;
}
else if (!strcmp("NINJA ASSAULT", naomi_game_id)
|| !strcmp(naomi_game_id, "Sports Shooting USA") // AW
|| !strcmp(naomi_game_id, "SEGA CLAY CHALLENGE")) // AW
{
printf("Enabling lightgun setup for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling lightgun setup for game %s", naomi_game_id);
settings.input.JammaSetup = 5;
}
else if (!strcmp(" BIOHAZARD GUN SURVIVOR2", naomi_game_id))
{
printf("Enabling specific JVS setup for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling specific JVS setup for game %s", naomi_game_id);
settings.input.JammaSetup = 7;
}
if (!strcmp("COSMIC SMASH IN JAPAN", naomi_game_id))
{
printf("Enabling translucent depth multipass for game %s\n", naomi_game_id);
INFO_LOG(BOOT, "Enabling translucent depth multipass for game %s", naomi_game_id);
settings.rend.TranslucentPolygonDepthMask = true;
tr_poly_depth_mask_game = true;
}
@ -303,7 +304,7 @@ int reicast_init(int argc, char* argv[])
#endif
if (!_vmem_reserve())
{
printf("Failed to alloc mem\n");
ERROR_LOG(VMEM, "Failed to alloc mem");
return -1;
}
if (ParseCommandLine(argc, argv))
@ -311,13 +312,18 @@ int reicast_init(int argc, char* argv[])
return 69;
}
InitSettings();
LogManager::Shutdown();
if (!cfgOpen())
{
printf("Config directory is not set. Starting onboarding\n");
LogManager::Init();
NOTICE_LOG(BOOT, "Config directory is not set. Starting onboarding");
gui_open_onboarding();
}
else
{
LogManager::Init();
LoadSettings(false);
}
os_CreateWindow();
os_SetupInput();
@ -392,10 +398,10 @@ int dc_start_game(const char *path)
}
else
{
printf("Did not load bios, using reios\n");
NOTICE_LOG(BOOT, "Did not load bios, using reios\n");
}
#else
printf("Cannot find BIOS files\n");
ERROR_LOG(BOOT, "Cannot find BIOS files\n");
return -5;
#endif
}
@ -415,14 +421,14 @@ int dc_start_game(const char *path)
sh4_cpu.Init(); // Also initialize the interpreter
if(settings.dynarec.Enable)
{
printf("Using Recompiler\n");
INFO_LOG(DYNAREC, "Using Recompiler");
}
else
#endif
{
Get_Sh4Interpreter(&sh4_cpu);
sh4_cpu.Init();
printf("Using Interpreter\n");
INFO_LOG(INTERPRETER, "Using Interpreter");
}
mem_Init();
@ -461,12 +467,12 @@ void* dc_run(void*)
if (settings.dynarec.Enable)
{
Get_Sh4Recompiler(&sh4_cpu);
printf("Using Recompiler\n");
INFO_LOG(DYNAREC, "Using Recompiler");
}
else
{
Get_Sh4Interpreter(&sh4_cpu);
printf("Using Interpreter\n");
INFO_LOG(DYNAREC, "Using Interpreter");
}
do {
reset_requested = false;
@ -877,7 +883,7 @@ void dc_savestate()
if ( ! dc_serialize(&data, &total_size) )
{
printf("Failed to save state - could not initialize total size\n") ;
WARN_LOG(SAVESTATE, "Failed to save state - could not initialize total size") ;
gui_display_notification("Save state failed", 2000);
cleanup_serialize(data) ;
return;
@ -886,7 +892,7 @@ void dc_savestate()
data = malloc(total_size) ;
if ( data == NULL )
{
printf("Failed to save state - could not malloc %d bytes", total_size) ;
WARN_LOG(SAVESTATE, "Failed to save state - could not malloc %d bytes", total_size) ;
gui_display_notification("Save state failed - memory full", 2000);
cleanup_serialize(data) ;
return;
@ -896,7 +902,7 @@ void dc_savestate()
if ( ! dc_serialize(&data_ptr, &total_size) )
{
printf("Failed to save state - could not serialize data\n") ;
WARN_LOG(SAVESTATE, "Failed to save state - could not serialize data") ;
gui_display_notification("Save state failed", 2000);
cleanup_serialize(data) ;
return;
@ -907,7 +913,7 @@ void dc_savestate()
if ( f == NULL )
{
printf("Failed to save state - could not open %s for writing\n", filename.c_str()) ;
WARN_LOG(SAVESTATE, "Failed to save state - could not open %s for writing", filename.c_str()) ;
gui_display_notification("Cannot open save file", 2000);
cleanup_serialize(data) ;
return;
@ -917,7 +923,7 @@ void dc_savestate()
fclose(f);
cleanup_serialize(data) ;
printf("Saved state to %s\n size %d", filename.c_str(), total_size) ;
INFO_LOG(SAVESTATE, "Saved state to %s size %d", filename.c_str(), total_size) ;
gui_display_notification("State saved", 1000);
}
@ -936,7 +942,7 @@ void dc_loadstate()
if ( f == NULL )
{
printf("Failed to load state - could not open %s for reading\n", filename.c_str()) ;
WARN_LOG(SAVESTATE, "Failed to load state - could not open %s for reading", filename.c_str()) ;
gui_display_notification("Save state not found", 2000);
cleanup_serialize(data) ;
return;
@ -947,7 +953,7 @@ void dc_loadstate()
data = malloc(total_size) ;
if ( data == NULL )
{
printf("Failed to load state - could not malloc %d bytes", total_size) ;
WARN_LOG(SAVESTATE, "Failed to load state - could not malloc %d bytes", total_size) ;
gui_display_notification("Failed to load state - memory full", 2000);
cleanup_serialize(data) ;
return;
@ -969,7 +975,7 @@ void dc_loadstate()
if ( ! dc_unserialize(&data_ptr, &total_size) )
{
printf("Failed to load state - could not unserialize data\n") ;
WARN_LOG(SAVESTATE, "Failed to load state - could not unserialize data") ;
gui_display_notification("Invalid save state", 2000);
cleanup_serialize(data) ;
return;
@ -982,5 +988,5 @@ void dc_loadstate()
CalculateSync();
cleanup_serialize(data) ;
printf("Loaded state from %s size %d\n", filename.c_str(), total_size) ;
INFO_LOG(SAVESTATE, "Loaded state from %s size %d", filename.c_str(), total_size) ;
}

View File

@ -579,10 +579,10 @@ static bool gles_init()
glGetIntegerv(GL_MINOR_VERSION, &minor);
if (major < 4 || (major == 4 && minor < 3))
{
printf("Warning: OpenGL version doesn't support per-pixel sorting.\n");
WARN_LOG(RENDERER, "Warning: OpenGL version doesn't support per-pixel sorting.");
return false;
}
printf("Per-pixel sorting enabled\n");
INFO_LOG(RENDERER, "Per-pixel sorting enabled");
glcache.DisableCache();
@ -758,7 +758,7 @@ static bool RenderFrame()
gl4ShaderUniforms.extra_depth_scale = settings.rend.ExtraDepthScale;
//printf("scale: %f, %f, %f, %f\n", gl4ShaderUniforms.scale_coefs[0], gl4ShaderUniforms.scale_coefs[1], gl4ShaderUniforms.scale_coefs[2], gl4ShaderUniforms.scale_coefs[3]);
DEBUG_LOG(RENDERER, "scale: %f, %f, %f, %f\n", gl4ShaderUniforms.scale_coefs[0], gl4ShaderUniforms.scale_coefs[1], gl4ShaderUniforms.scale_coefs[2], gl4ShaderUniforms.scale_coefs[3]);
//VERT and RAM fog color constants
u8* fog_colvert_bgra=(u8*)&FOG_COL_VERT;
@ -832,15 +832,15 @@ static bool RenderFrame()
case 4: //0x4 888 RGB 24 bit packed
case 5: //0x5 0888 KRGB 32 bit K is the value of fk_kval.
case 6: //0x6 8888 ARGB 32 bit
fprintf(stderr, "Unsupported render to texture format: %d\n", FB_W_CTRL.fb_packmode);
WARN_LOG(RENDERER, "Unsupported render to texture format: %d", FB_W_CTRL.fb_packmode);
return false;
case 7: //7 invalid
die("7 is not valid");
break;
}
//printf("RTT packmode=%d stride=%d - %d,%d -> %d,%d\n", FB_W_CTRL.fb_packmode, FB_W_LINESTRIDE.stride * 8,
// FB_X_CLIP.min, FB_Y_CLIP.min, FB_X_CLIP.max, FB_Y_CLIP.max);
DEBUG_LOG(RENDERER, "RTT packmode=%d stride=%d - %d,%d -> %d,%d", FB_W_CTRL.fb_packmode, FB_W_LINESTRIDE.stride * 8,
FB_X_CLIP.min, FB_Y_CLIP.min, FB_X_CLIP.max, FB_Y_CLIP.max);
output_fbo = gl4BindRTT(FB_W_SOF1 & VRAM_MASK, dc_width, dc_height, channels, format);
}
else
@ -896,9 +896,9 @@ static bool RenderFrame()
#if 0
//handy to debug really stupid render-not-working issues ...
printf("SS: %dx%d\n", screen_width, screen_height);
printf("SCI: %d, %f\n", pvrrc.fb_X_CLIP.max, dc2s_scale_h);
printf("SCI: %f, %f, %f, %f\n", offs_x+pvrrc.fb_X_CLIP.min/scale_x,(pvrrc.fb_Y_CLIP.min/scale_y)*dc2s_scale_h,(pvrrc.fb_X_CLIP.max-pvrrc.fb_X_CLIP.min+1)/scale_x*dc2s_scale_h,(pvrrc.fb_Y_CLIP.max-pvrrc.fb_Y_CLIP.min+1)/scale_y*dc2s_scale_h);
DEBUG_LOG(RENDERER, "SS: %dx%d", screen_width, screen_height);
DEBUG_LOG(RENDERER, "SCI: %d, %f", pvrrc.fb_X_CLIP.max, dc2s_scale_h);
DEBUG_LOG(RENDERER, "SCI: %f, %f, %f, %f", offs_x+pvrrc.fb_X_CLIP.min/scale_x,(pvrrc.fb_Y_CLIP.min/scale_y)*dc2s_scale_h,(pvrrc.fb_X_CLIP.max-pvrrc.fb_X_CLIP.min+1)/scale_x*dc2s_scale_h,(pvrrc.fb_Y_CLIP.max-pvrrc.fb_Y_CLIP.min+1)/scale_y*dc2s_scale_h);
#endif
if (!wide_screen_on)
@ -1027,7 +1027,7 @@ struct gl4rend : Renderer
bool Process(TA_context* ctx) { return ProcessFrame(ctx); }
bool Render() { return RenderFrame(); }
bool RenderLastFrame() { return gl4_render_output_framebuffer(); }
bool RenderLastFrame() { return gl.swap_buffer_not_preserved ? gl4_render_output_framebuffer() : false; }
void Present() { gl_swap(); }

View File

@ -453,7 +453,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
FILE *fp = fopen("screenshot.png", "wb");
if (fp == NULL)
{
printf("Failed to open screenshot.png for writing\n");
ERROR_LOG(RENDERER, "Failed to open screenshot.png for writing\n");
return;
}
@ -519,7 +519,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
EGLint maj, min;
if (!eglInitialize(gl.setup.display, &maj, &min))
{
printf("EGL Error: eglInitialize failed\n");
ERROR_LOG(RENDERER, "EGL Error: eglInitialize failed");
return false;
}
@ -548,7 +548,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
};
if (!eglChooseConfig(gl.setup.display, pi32ConfigFallbackAttribs, &config, 1, &num_config) || (num_config != 1))
{
printf("EGL Error: eglChooseConfig failed\n");
ERROR_LOG(RENDERER, "EGL Error: eglChooseConfig failed");
return false;
}
}
@ -556,7 +556,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
EGLint format;
if (!eglGetConfigAttrib(gl.setup.display, config, EGL_NATIVE_VISUAL_ID, &format))
{
printf("eglGetConfigAttrib() returned error %x\n", eglGetError());
ERROR_LOG(RENDERER, "eglGetConfigAttrib() returned error %x", eglGetError());
return false;
}
ANativeWindow_setBuffersGeometry((ANativeWindow *)wind, 0, 0, format);
@ -565,7 +565,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
if (gl.setup.surface == EGL_NO_SURFACE)
{
printf("EGL Error: eglCreateWindowSurface failed: %x\n", eglGetError());
ERROR_LOG(RENDERER, "EGL Error: eglCreateWindowSurface failed: %x", eglGetError());
return false;
}
@ -573,7 +573,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
bool try_full_gl = true;
if (!eglBindAPI(EGL_OPENGL_API))
{
printf("eglBindAPI(EGL_OPENGL_API) failed: %x\n", eglGetError());
INFO_LOG(RENDERER, "eglBindAPI(EGL_OPENGL_API) failed: %x", eglGetError());
try_full_gl = false;
}
if (try_full_gl)
@ -586,7 +586,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
{
egl_makecurrent();
if (gl3wInit())
printf("gl3wInit() failed\n");
ERROR_LOG(RENDERER, "gl3wInit() failed");
}
}
#endif
@ -594,7 +594,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
{
if (!eglBindAPI(EGL_OPENGL_ES_API))
{
printf("eglBindAPI() failed: %x\n", eglGetError());
ERROR_LOG(RENDERER, "eglBindAPI() failed: %x", eglGetError());
return false;
}
EGLint contextAttrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2 , EGL_NONE };
@ -603,7 +603,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
if (gl.setup.context == EGL_NO_CONTEXT)
{
printf("eglCreateContext() failed: %x\n", eglGetError());
ERROR_LOG(RENDERER, "eglCreateContext() failed: %x", eglGetError());
return false;
}
#ifdef GLES
@ -612,7 +612,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
#else
egl_makecurrent();
if (gl3wInit())
printf("gl3wInit() failed\n");
INFO_LOG(RENDERER, "gl3wInit() failed");
#endif
}
created_context = true;
@ -625,7 +625,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
if (!egl_makecurrent())
{
printf("eglMakeCurrent() failed: %x\n", eglGetError());
ERROR_LOG(RENDERER, "eglMakeCurrent() failed: %x", eglGetError());
return false;
}
@ -639,11 +639,11 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
// Required when doing partial redraws
if (!eglSurfaceAttrib(gl.setup.display, gl.setup.surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED))
{
printf("Swap buffers are not preserved. Last frame copy enabled\n");
INFO_LOG(RENDERER, "Swap buffers are not preserved. Last frame copy enabled");
gl.swap_buffer_not_preserved = true;
}
printf("EGL config: %p, %p, %p %dx%d\n",gl.setup.context,gl.setup.display,gl.setup.surface,w,h);
INFO_LOG(RENDERER, "EGL config: %p, %p, %p %dx%d", gl.setup.context, gl.setup.display, gl.setup.surface, w, h);
return true;
}
@ -801,7 +801,7 @@ void dump_screenshot(u8 *buffer, u32 width, u32 height)
if (!m_hrc)
{
printf("Open GL 4.3 not supported\n");
INFO_LOG(RENDERER, "Open GL 4.3 not supported");
// Try Gl 3.1
attribs[1] = 3;
attribs[3] = 1;
@ -966,7 +966,7 @@ void findGLVersion()
if (glGetError() == GL_INVALID_ENUM)
gl.gl_major = 2;
const char *version = (const char *)glGetString(GL_VERSION);
printf("OpenGL version: %s\n", version);
INFO_LOG(RENDERER, "OpenGL version: %s", version);
if (!strncmp(version, "OpenGL ES", 9))
{
gl.is_gles = true;
@ -988,7 +988,7 @@ void findGLVersion()
if (strstr(extensions, "GL_OES_depth24") != NULL)
gl.GL_OES_depth24_supported = true;
if (!gl.GL_OES_packed_depth_stencil_supported)
printf("Packed depth/stencil not supported: no modifier volumes when rendering to a texture\n");
INFO_LOG(RENDERER, "Packed depth/stencil not supported: no modifier volumes when rendering to a texture");
}
else
{
@ -1032,7 +1032,7 @@ GLuint gl_CompileShader(const char* shader,GLuint type)
*compile_log=0;
glGetShaderInfoLog(rv, compile_log_len, &compile_log_len, compile_log);
printf("Shader: %s \n%s\n",result?"compiled!":"failed to compile",compile_log);
WARN_LOG(RENDERER, "Shader: %s \n%s", result ? "compiled!" : "failed to compile", compile_log);
free(compile_log);
}
@ -1080,13 +1080,13 @@ GLuint gl_CompileAndLink(const char* VertexShader, const char* FragmentShader)
*compile_log=0;
glGetProgramInfoLog(program, compile_log_len, &compile_log_len, compile_log);
printf("Shader linking: %s \n (%d bytes), - %s -\n",result?"linked":"failed to link", compile_log_len,compile_log);
WARN_LOG(RENDERER, "Shader linking: %s \n (%d bytes), - %s -", result ? "linked" : "failed to link", compile_log_len, compile_log);
free(compile_log);
// Dump the shaders source for troubleshooting
printf("// VERTEX SHADER\n%s\n// END\n", VertexShader);
printf("// FRAGMENT SHADER\n%s\n// END\n", FragmentShader);
INFO_LOG(RENDERER, "// VERTEX SHADER\n%s\n// END", VertexShader);
INFO_LOG(RENDERER, "// FRAGMENT SHADER\n%s\n// END", FragmentShader);
die("shader compile fail\n");
}
@ -1578,7 +1578,7 @@ bool ProcessFrame(TA_context* ctx)
CollectCleanup();
if (ctx->rend.Overrun)
printf("ERROR: TA context overrun\n");
WARN_LOG(PVR, "ERROR: TA context overrun");
return !ctx->rend.Overrun;
}
@ -1895,15 +1895,15 @@ bool RenderFrame()
case 4: //0x4 888 RGB 24 bit packed
case 5: //0x5 0888 KRGB 32 bit K is the value of fk_kval.
case 6: //0x6 8888 ARGB 32 bit
fprintf(stderr, "Unsupported render to texture format: %d\n", FB_W_CTRL.fb_packmode);
WARN_LOG(RENDERER, "Unsupported render to texture format: %d", FB_W_CTRL.fb_packmode);
return false;
case 7: //7 invalid
die("7 is not valid");
break;
}
//printf("RTT packmode=%d stride=%d - %d,%d -> %d,%d\n", FB_W_CTRL.fb_packmode, FB_W_LINESTRIDE.stride * 8,
// FB_X_CLIP.min, FB_Y_CLIP.min, FB_X_CLIP.max, FB_Y_CLIP.max);
DEBUG_LOG(RENDERER, "RTT packmode=%d stride=%d - %d,%d -> %d,%d", FB_W_CTRL.fb_packmode, FB_W_LINESTRIDE.stride * 8,
FB_X_CLIP.min, FB_Y_CLIP.min, FB_X_CLIP.max, FB_Y_CLIP.max);
BindRTT(FB_W_SOF1 & VRAM_MASK, dc_width, dc_height, channels, format);
}
else
@ -2069,7 +2069,7 @@ struct glesrend : Renderer
bool Process(TA_context* ctx) { return ProcessFrame(ctx); }
bool Render() { return RenderFrame(); }
bool RenderLastFrame() { return render_output_framebuffer(); }
bool RenderLastFrame() { return gl.swap_buffer_not_preserved ? render_output_framebuffer() : false; }
void Present() { gl_swap(); glViewport(0, 0, screen_width, screen_height); }
void DrawOSD(bool clear_screen)
@ -2127,7 +2127,7 @@ u8* loadPNGData(const string& fname, int &width, int &height)
if (!is_png)
{
fclose(file);
printf("Not a PNG file : %s\n", filename);
WARN_LOG(RENDERER, "Not a PNG file : %s", filename);
return NULL;
}
@ -2137,7 +2137,7 @@ u8* loadPNGData(const string& fname, int &width, int &height)
if (!png_ptr)
{
fclose(file);
printf("Unable to create PNG struct : %s\n", filename);
WARN_LOG(RENDERER, "Unable to create PNG struct : %s", filename);
return (NULL);
}
@ -2146,7 +2146,7 @@ u8* loadPNGData(const string& fname, int &width, int &height)
if (!info_ptr)
{
png_destroy_read_struct(&png_ptr, (png_infopp) NULL, (png_infopp) NULL);
printf("Unable to create PNG info : %s\n", filename);
WARN_LOG(RENDERER, "Unable to create PNG info : %s", filename);
fclose(file);
return (NULL);
}
@ -2156,7 +2156,7 @@ u8* loadPNGData(const string& fname, int &width, int &height)
if (!end_info)
{
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
printf("Unable to create PNG end info : %s\n", filename);
WARN_LOG(RENDERER, "Unable to create PNG end info : %s", filename);
fclose(file);
return (NULL);
}
@ -2165,7 +2165,7 @@ u8* loadPNGData(const string& fname, int &width, int &height)
if (setjmp(png_jmpbuf(png_ptr)))
{
fclose(file);
printf("Error during setjmp : %s\n", filename);
WARN_LOG(RENDERER, "Error during setjmp : %s", filename);
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return (NULL);
}
@ -2204,7 +2204,7 @@ u8* loadPNGData(const string& fname, int &width, int &height)
{
//clean up memory and close stuff
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
printf("Unable to allocate image_data while loading %s\n", filename);
WARN_LOG(RENDERER, "Unable to allocate image_data while loading %s", filename);
fclose(file);
return NULL;
}
@ -2216,7 +2216,7 @@ u8* loadPNGData(const string& fname, int &width, int &height)
//clean up memory and close stuff
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
delete[] image_data;
printf("Unable to allocate row_pointer while loading %s\n", filename);
WARN_LOG(RENDERER, "Unable to allocate row_pointer while loading %s", filename);
fclose(file);
return NULL;
}

View File

@ -1526,7 +1526,7 @@ bool dc_unserialize(void **data, unsigned int *total_size)
return dc_unserialize_libretro(data, total_size);
if (version != V4)
{
fprintf(stderr, "Save State version not supported: %d\n", version);
WARN_LOG(SAVESTATE, "Save State version not supported: %d", version);
return false;
}
REICAST_US(aica_interr) ;

View File

@ -64,7 +64,7 @@ public:
if (data)
{
#ifdef MEM_ALLOC_TRACE
printf("WARNING : DESTRUCTOR WITH NON FREED ARRAY [arrayid:%d]\n",id);
DEBUG_LOG(COMMON, "WARNING : DESTRUCTOR WITH NON FREED ARRAY [arrayid:%d]", id);
#endif
Free();
}
@ -85,7 +85,7 @@ public:
if (data)
{
#ifdef MEM_ALLOC_TRACE
printf("Freeing data -> resize to zero[Array:%d]\n",id);
DEBUG_LOG(COMMON, "Freeing data -> resize to zero[Array:%d]", id);
#endif
Free();
}
@ -140,7 +140,7 @@ public:
#ifdef MEM_BOUND_CHECK
if (i>=Size)
{
printf("Error: Array %d , index out of range (%d>%d)\n",id,i,Size-1);
ERROR_LOG(COMMON, "Error: Array %d , index out of range (%d > %d)", id, i, Size - 1);
MEM_DO_BREAK;
}
#endif
@ -152,7 +152,7 @@ public:
#ifdef MEM_BOUND_CHECK
if (!(i>=0 && i<(s32)Size))
{
printf("Error: Array %d , index out of range (%d > %d)\n",id,i,Size-1);
ERROR_LOG(COMMON, "Error: Array %d , index out of range (%d > %d)", id, i, Size - 1);
MEM_DO_BREAK;
}
#endif
@ -308,7 +308,7 @@ public:
#ifdef MEM_BOUND_CHECK
if (i >= size)
{
printf("Error: VLockedMemory , index out of range (%d > %d)\n", i, size-1);
ERROR_LOG(COMMON, "Error: VLockedMemory , index out of range (%d > %d)\n", i, size - 1);
MEM_DO_BREAK;
}
#endif
@ -318,55 +318,6 @@ public:
int msgboxf(const wchar* text,unsigned int type,...);
#define MBX_OK 0x00000000L
#define MBX_OKCANCEL 0x00000001L
#define MBX_ABORTRETRYIGNORE 0x00000002L
#define MBX_YESNOCANCEL 0x00000003L
#define MBX_YESNO 0x00000004L
#define MBX_RETRYCANCEL 0x00000005L
#define MBX_ICONHAND 0x00000010L
#define MBX_ICONQUESTION 0x00000020L
#define MBX_ICONEXCLAMATION 0x00000030L
#define MBX_ICONASTERISK 0x00000040L
#define MBX_USERICON 0x00000080L
#define MBX_ICONWARNING MBX_ICONEXCLAMATION
#define MBX_ICONERROR MBX_ICONHAND
#define MBX_ICONINFORMATION MBX_ICONASTERISK
#define MBX_ICONSTOP MBX_ICONHAND
#define MBX_DEFBUTTON1 0x00000000L
#define MBX_DEFBUTTON2 0x00000100L
#define MBX_DEFBUTTON3 0x00000200L
#define MBX_DEFBUTTON4 0x00000300L
#define MBX_APPLMODAL 0x00000000L
#define MBX_SYSTEMMODAL 0x00001000L
#define MBX_TASKMODAL 0x00002000L
#define MBX_HELP 0x00004000L // Help Button
#define MBX_NOFOCUS 0x00008000L
#define MBX_SETFOREGROUND 0x00010000L
#define MBX_DEFAULT_DESKTOP_ONLY 0x00020000L
#define MBX_TOPMOST 0x00040000L
#define MBX_RIGHT 0x00080000L
#define MBX_RTLREADING 0x00100000L
#define MBX_RV_OK 1
#define MBX_RV_CANCEL 2
#define MBX_RV_ABORT 3
#define MBX_RV_RETRY 4
#define MBX_RV_IGNORE 5
#define MBX_RV_YES 6
#define MBX_RV_NO 7
#define MBX_OK 0
#define MBX_ICONEXCLAMATION 0
#define MBX_ICONERROR 0

View File

@ -385,13 +385,9 @@ using namespace std;
//basic includes
#include "stdclass.h"
#ifndef RELEASE
#define EMUERROR(format, ...) printf("Error in %20s:%s:%d: " format "\n", \
__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
//strlen(__FILE__) <= 20 ? __FILE__ : __FILE__ + strlen(__FILE__) - 20,
#else
#define EMUERROR(format, ...)
#endif
#include "log/Log.h"
#define EMUERROR(...) INFO_LOG(COMMON, __VA_ARGS__)
#define EMUERROR2 EMUERROR
#define EMUERROR3 EMUERROR
#define EMUERROR4 EMUERROR

View File

@ -7,6 +7,7 @@
#include "xinput_gamepad.h"
#include "win_keyboard.h"
#include "hw/sh4/dyna/blockmanager.h"
#include "log/LogManager.h"
#define _WIN32_WINNT 0x0500
#include <windows.h>
@ -695,6 +696,7 @@ int main(int argc, char **argv)
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShowCmd)
{
LogManager::Init();
int argc=0;
wchar* cmd_line=GetCommandLineA();
wchar** argv=CommandLineToArgvA(cmd_line,&argc);

View File

@ -24,6 +24,7 @@
#include "imgread/common.h"
#include "rend/gui.h"
#include "cfg/cfg.h"
#include "log/LogManager.h"
JavaVM* g_jvm;
@ -230,6 +231,7 @@ JNIEXPORT jstring JNICALL Java_com_reicast_emulator_emu_JNIdc_initEnvironment(JN
if (first_init)
{
// Do one-time initialization
LogManager::Init();
jstring msg = NULL;
int rc = reicast_init(0, NULL);
if (rc == -4)

View File

@ -12,6 +12,7 @@
#include "types.h"
#include "hw/maple/maple_cfg.h"
#include "log/LogManager.h"
#include "rend/gui.h"
#include "osx_keyboard.h"
#include "osx_gamepad.h"
@ -161,6 +162,7 @@ extern "C" void emu_gles_init(int width, int height) {
extern "C" int emu_reicast_init()
{
LogManager::Init();
common_linux_setup();
return reicast_init(0, NULL);
}