2013-09-05 05:47:46 +05:30
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-08-17 23:15:50 +05:30
|
|
|
#pragma once
|
2013-09-05 05:47:46 +05:30
|
|
|
|
2014-12-05 02:27:00 +05:30
|
|
|
#include "common/common_funcs.h"
|
|
|
|
#include "common/msg_handler.h"
|
2014-10-28 13:06:00 +05:30
|
|
|
#include "common/logging/log.h"
|
2014-12-05 02:27:00 +05:30
|
|
|
|
2014-08-23 06:39:14 +05:30
|
|
|
#ifndef LOGGING
|
2014-05-10 06:24:51 +05:30
|
|
|
#define LOGGING
|
2014-08-23 06:39:14 +05:30
|
|
|
#endif
|
2014-05-10 06:24:51 +05:30
|
|
|
|
2014-05-30 08:33:03 +05:30
|
|
|
enum {
|
|
|
|
OS_LEVEL, // Printed by the emulated operating system
|
|
|
|
NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports.
|
2014-11-19 14:19:13 +05:30
|
|
|
ERROR_LEVEL, // Critical errors
|
2014-05-30 08:33:03 +05:30
|
|
|
WARNING_LEVEL, // Something is suspicious.
|
|
|
|
INFO_LEVEL, // General information.
|
|
|
|
DEBUG_LEVEL, // Detailed debugging - might make things slow.
|
|
|
|
};
|
2013-09-05 05:47:46 +05:30
|
|
|
|
|
|
|
namespace LogTypes
|
|
|
|
{
|
|
|
|
|
|
|
|
enum LOG_TYPE {
|
2014-10-28 13:06:00 +05:30
|
|
|
//ACTIONREPLAY,
|
|
|
|
//AUDIO,
|
|
|
|
//AUDIO_INTERFACE,
|
2014-04-02 03:50:08 +05:30
|
|
|
BOOT,
|
2014-10-28 13:06:00 +05:30
|
|
|
//COMMANDPROCESSOR,
|
2014-04-02 03:50:08 +05:30
|
|
|
COMMON,
|
2014-10-28 13:06:00 +05:30
|
|
|
//CONSOLE,
|
2014-09-13 05:36:13 +05:30
|
|
|
CONFIG,
|
2014-10-28 13:06:00 +05:30
|
|
|
//DISCIO,
|
|
|
|
//FILEMON,
|
|
|
|
//DSPHLE,
|
|
|
|
//DSPLLE,
|
|
|
|
//DSP_MAIL,
|
|
|
|
//DSPINTERFACE,
|
|
|
|
//DVDINTERFACE,
|
|
|
|
//DYNA_REC,
|
|
|
|
//EXPANSIONINTERFACE,
|
|
|
|
//GDB_STUB,
|
2014-04-02 03:50:08 +05:30
|
|
|
ARM11,
|
2014-05-08 06:29:21 +05:30
|
|
|
GSP,
|
2014-04-02 03:50:08 +05:30
|
|
|
OSHLE,
|
|
|
|
MASTER_LOG,
|
|
|
|
MEMMAP,
|
2014-10-28 13:06:00 +05:30
|
|
|
//MEMCARD_MANAGER,
|
|
|
|
//OSREPORT,
|
|
|
|
//PAD,
|
|
|
|
//PROCESSORINTERFACE,
|
|
|
|
//PIXELENGINE,
|
|
|
|
//SERIALINTERFACE,
|
|
|
|
//SP1,
|
|
|
|
//STREAMINGINTERFACE,
|
2014-04-02 03:50:08 +05:30
|
|
|
VIDEO,
|
2014-10-28 13:06:00 +05:30
|
|
|
//VIDEOINTERFACE,
|
2014-04-02 03:50:08 +05:30
|
|
|
LOADER,
|
|
|
|
FILESYS,
|
2014-10-28 13:06:00 +05:30
|
|
|
//WII_IPC_DVD,
|
|
|
|
//WII_IPC_ES,
|
|
|
|
//WII_IPC_FILEIO,
|
|
|
|
//WII_IPC_HID,
|
2014-05-10 06:24:51 +05:30
|
|
|
KERNEL,
|
2014-05-07 02:48:20 +05:30
|
|
|
SVC,
|
2014-04-11 08:13:48 +05:30
|
|
|
HLE,
|
2014-04-07 02:26:42 +05:30
|
|
|
RENDER,
|
2014-05-18 02:20:33 +05:30
|
|
|
GPU,
|
2014-04-05 08:23:34 +05:30
|
|
|
HW,
|
2014-04-02 03:50:08 +05:30
|
|
|
TIME,
|
2014-10-28 13:06:00 +05:30
|
|
|
//NETPLAY,
|
2014-11-13 22:02:03 +05:30
|
|
|
GUI,
|
2014-04-02 03:50:08 +05:30
|
|
|
|
|
|
|
NUMBER_OF_LOGS // Must be last
|
2013-09-05 05:47:46 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
// FIXME: should this be removed?
|
|
|
|
enum LOG_LEVELS {
|
2014-05-30 08:33:03 +05:30
|
|
|
LOS = OS_LEVEL,
|
2014-04-02 03:50:08 +05:30
|
|
|
LNOTICE = NOTICE_LEVEL,
|
|
|
|
LERROR = ERROR_LEVEL,
|
|
|
|
LWARNING = WARNING_LEVEL,
|
|
|
|
LINFO = INFO_LEVEL,
|
|
|
|
LDEBUG = DEBUG_LEVEL,
|
2013-09-05 05:47:46 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
#define LOGTYPES_LEVELS LogTypes::LOG_LEVELS
|
|
|
|
#define LOGTYPES_TYPE LogTypes::LOG_TYPE
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2014-11-19 14:19:13 +05:30
|
|
|
void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line,
|
2014-05-30 08:33:03 +05:30
|
|
|
const char* function, const char* fmt, ...)
|
2013-09-05 05:47:46 +05:30
|
|
|
#ifdef __GNUC__
|
2014-06-01 20:27:45 +05:30
|
|
|
__attribute__((format(printf, 6, 7)))
|
2013-09-05 05:47:46 +05:30
|
|
|
#endif
|
2014-04-02 03:50:08 +05:30
|
|
|
;
|
2013-09-05 05:47:46 +05:30
|
|
|
|
|
|
|
#if defined LOGGING || defined _DEBUG || defined DEBUGFAST
|
2014-06-01 21:19:58 +05:30
|
|
|
#define MAX_LOGLEVEL LDEBUG
|
2013-09-05 05:47:46 +05:30
|
|
|
#else
|
|
|
|
#ifndef MAX_LOGLEVEL
|
2014-06-01 21:19:58 +05:30
|
|
|
#define MAX_LOGLEVEL LWARNING
|
2013-09-05 05:47:46 +05:30
|
|
|
#endif // loglevel
|
|
|
|
#endif // logging
|
|
|
|
|
2014-05-30 08:33:03 +05:30
|
|
|
#ifdef _WIN32
|
|
|
|
#ifndef __func__
|
|
|
|
#define __func__ __FUNCTION__
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2013-09-05 05:47:46 +05:30
|
|
|
// Let the compiler optimize this out
|
|
|
|
#define GENERIC_LOG(t, v, ...) { \
|
2014-06-01 21:19:58 +05:30
|
|
|
if (v <= LogTypes::MAX_LOGLEVEL) \
|
2014-05-30 08:33:03 +05:30
|
|
|
GenericLog(v, t, __FILE__, __LINE__, __func__, __VA_ARGS__); \
|
2014-04-02 03:50:08 +05:30
|
|
|
}
|
2013-09-05 05:47:46 +05:30
|
|
|
|
2014-10-28 13:06:00 +05:30
|
|
|
//#define OS_LOG(t,...) do { GENERIC_LOG(LogTypes::t, LogTypes::LOS, __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)
|
|
|
|
|
2014-12-06 07:23:49 +05:30
|
|
|
//#define OS_LOG(t,...) LOG_INFO(Common, __VA_ARGS__)
|
|
|
|
//#define ERROR_LOG(t,...) LOG_ERROR(Common_Filesystem, __VA_ARGS__)
|
|
|
|
//#define WARN_LOG(t,...) LOG_WARNING(Kernel_SVC, __VA_ARGS__)
|
|
|
|
//#define NOTICE_LOG(t,...) LOG_INFO(Service, __VA_ARGS__)
|
|
|
|
//#define INFO_LOG(t,...) LOG_INFO(Service_FS, __VA_ARGS__)
|
|
|
|
//#define DEBUG_LOG(t,...) LOG_DEBUG(Common, __VA_ARGS__)
|
2013-09-05 05:47:46 +05:30
|
|
|
|
|
|
|
#if MAX_LOGLEVEL >= DEBUG_LEVEL
|
|
|
|
#define _dbg_assert_(_t_, _a_) \
|
2014-04-02 03:50:08 +05:30
|
|
|
if (!(_a_)) {\
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_CRITICAL(_t_, "Error...\n\n Line: %d\n File: %s\n Time: %s\n\nIgnore and continue?", \
|
2014-04-02 03:50:08 +05:30
|
|
|
__LINE__, __FILE__, __TIME__); \
|
|
|
|
if (!PanicYesNo("*** Assertion (see log)***\n")) {Crash();} \
|
|
|
|
}
|
2013-09-05 05:47:46 +05:30
|
|
|
#define _dbg_assert_msg_(_t_, _a_, ...)\
|
2014-04-02 03:50:08 +05:30
|
|
|
if (!(_a_)) {\
|
2014-12-06 07:23:49 +05:30
|
|
|
LOG_CRITICAL(_t_, __VA_ARGS__); \
|
2014-04-02 03:50:08 +05:30
|
|
|
if (!PanicYesNo(__VA_ARGS__)) {Crash();} \
|
|
|
|
}
|
2013-09-05 05:47:46 +05:30
|
|
|
#define _dbg_update_() Host_UpdateLogDisplay();
|
|
|
|
|
|
|
|
#else // not debug
|
|
|
|
#define _dbg_update_() ;
|
|
|
|
|
|
|
|
#ifndef _dbg_assert_
|
|
|
|
#define _dbg_assert_(_t_, _a_) {}
|
|
|
|
#define _dbg_assert_msg_(_t_, _a_, _desc_, ...) {}
|
|
|
|
#endif // dbg_assert
|
|
|
|
#endif // MAX_LOGLEVEL DEBUG
|
|
|
|
|
|
|
|
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
|
|
|
|
|
|
|
|
#ifndef GEKKO
|
|
|
|
#ifdef _WIN32
|
2014-04-02 03:50:08 +05:30
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
|
|
|
|
if (!(_a_)) {\
|
|
|
|
if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \
|
|
|
|
}
|
2013-09-05 05:47:46 +05:30
|
|
|
#else // not win32
|
2014-04-02 03:50:08 +05:30
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...) \
|
|
|
|
if (!(_a_)) {\
|
|
|
|
if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \
|
|
|
|
}
|
2013-09-05 05:47:46 +05:30
|
|
|
#endif // WIN32
|
|
|
|
#else // GEKKO
|
|
|
|
#define _assert_msg_(_t_, _a_, _fmt_, ...)
|
|
|
|
#endif
|