Skip to content
Permalink
Browse files

Common: Unify logging namespace with Common

Previously the logging was a in a little bit of a disarray. Some things
were in namespaces, and other things were not.

Given this code will feature a bit of restructuring during the
transition over to fmt, this is a good time to unify it under a single
namespace and also remove functions and types from the global namespace.

Now, all functions and types are under the Common::Log namespace. The
only outliers being, of course, the preprocessor macros.
  • Loading branch information
lioncash committed Nov 28, 2019
1 parent c2c8a14 commit c792961000a6bc8fa33dabdf42d07a25e44e8662
Showing with 261 additions and 245 deletions.
  1. +3 −3 Source/Core/AudioCommon/CubebUtils.cpp
  2. +3 −3 Source/Core/Common/Assert.h
  3. +2 −2 Source/Core/Common/Logging/ConsoleListener.h
  4. +6 −6 Source/Core/Common/Logging/ConsoleListenerDroid.cpp
  5. +4 −4 Source/Core/Common/Logging/ConsoleListenerNix.cpp
  6. +1 −1 Source/Core/Common/Logging/ConsoleListenerWin.cpp
  7. +12 −13 Source/Core/Common/Logging/Log.h
  8. +66 −64 Source/Core/Common/Logging/LogManager.cpp
  9. +17 −14 Source/Core/Common/Logging/LogManager.h
  10. +1 −1 Source/Core/Core/ActionReplay.cpp
  11. +5 −4 Source/Core/Core/Debugger/Debugger_SymbolMap.cpp
  12. +2 −2 Source/Core/Core/Debugger/Debugger_SymbolMap.h
  13. +4 −1 Source/Core/Core/HW/DVD/FileMonitor.cpp
  14. +4 −4 Source/Core/Core/HW/SI/SI_DeviceGBA.cpp
  15. +1 −1 Source/Core/Core/IOS/DI/DI.cpp
  16. +10 −10 Source/Core/Core/IOS/Device.cpp
  17. +10 −10 Source/Core/Core/IOS/Device.h
  18. +1 −1 Source/Core/Core/IOS/ES/ES.cpp
  19. +2 −1 Source/Core/Core/IOS/FS/FileSystemProxy.cpp
  20. +9 −9 Source/Core/Core/IOS/Network/IP/Top.cpp
  21. +1 −1 Source/Core/Core/IOS/Network/KD/NetKDRequest.cpp
  22. +1 −1 Source/Core/Core/IOS/Network/KD/NetKDTime.cpp
  23. +2 −2 Source/Core/Core/IOS/Network/SSL.cpp
  24. +1 −1 Source/Core/Core/IOS/Network/Socket.cpp
  25. +1 −1 Source/Core/Core/IOS/Network/WD/Command.cpp
  26. +1 −1 Source/Core/Core/IOS/STM/STM.cpp
  27. +3 −3 Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp
  28. +1 −9 Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp
  29. +6 −6 Source/Core/Core/IOS/USB/OH0/OH0.cpp
  30. +2 −2 Source/Core/Core/IOS/USB/USB_HID/HIDv4.cpp
  31. +3 −3 Source/Core/Core/IOS/USB/USB_HID/HIDv5.cpp
  32. +2 −2 Source/Core/Core/IOS/USB/USB_VEN/VEN.cpp
  33. +1 −1 Source/Core/Core/IOS/WFS/WFSI.cpp
  34. +1 −1 Source/Core/Core/IOS/WFS/WFSSRV.cpp
  35. +41 −35 Source/Core/DolphinQt/Config/LogConfigWidget.cpp
  36. +10 −9 Source/Core/DolphinQt/Config/LogWidget.cpp
  37. +3 −3 Source/Core/DolphinQt/Config/LogWidget.h
  38. +2 −2 Source/Core/UICommon/UICommon.cpp
  39. +8 −2 Source/Core/VideoBackends/OGL/Render.cpp
  40. +4 −4 Source/Core/VideoBackends/Vulkan/VulkanContext.cpp
  41. +2 −1 Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp
  42. +2 −1 Source/Core/VideoBackends/Vulkan/main.cpp
@@ -18,7 +18,7 @@ static ptrdiff_t s_path_cutoff_point = 0;

static void LogCallback(const char* format, ...)
{
if (!LogManager::GetInstance())
if (!Common::Log::LogManager::GetInstance())
return;

va_list args;
@@ -28,8 +28,8 @@ static void LogCallback(const char* format, ...)
int lineno = va_arg(args, int);
std::string adapted_format(StripSpaces(format + strlen("%s:%d:")));

LogManager::GetInstance()->LogWithFullPath(LogTypes::LNOTICE, LogTypes::AUDIO, filename, lineno,
adapted_format.c_str(), args);
Common::Log::LogManager::GetInstance()->LogWithFullPath(
Common::Log::LNOTICE, Common::Log::AUDIO, filename, lineno, adapted_format.c_str(), args);
va_end(args);
}

@@ -23,7 +23,7 @@
#define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \
do \
{ \
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) \
if (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG && !(_a_)) \
{ \
ERROR_LOG(_t_, _msg_, __VA_ARGS__); \
if (!PanicYesNo(_msg_, __VA_ARGS__)) \
@@ -44,7 +44,7 @@
#define DEBUG_ASSERT_MSG(_t_, _a_, _msg_, ...) \
do \
{ \
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG && !(_a_)) \
if (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG && !(_a_)) \
{ \
ERROR_LOG(_t_, _msg_, ##__VA_ARGS__); \
if (!PanicYesNo(_msg_, ##__VA_ARGS__)) \
@@ -64,6 +64,6 @@
#define DEBUG_ASSERT(_a_) \
do \
{ \
if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) \
if (MAX_LOGLEVEL >= Common::Log::LOG_LEVELS::LDEBUG) \
ASSERT(_a_); \
} while (0)
@@ -6,13 +6,13 @@

#include "Common/Logging/LogManager.h"

class ConsoleListener : public LogListener
class ConsoleListener : public Common::Log::LogListener
{
public:
ConsoleListener();
~ConsoleListener();

void Log(LogTypes::LOG_LEVELS, const char* text) override;
void Log(Common::Log::LOG_LEVELS level, const char* text) override;

private:
bool m_use_color;
@@ -14,26 +14,26 @@ ConsoleListener::~ConsoleListener()
{
}

void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
void ConsoleListener::Log(Common::Log::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:
case Common::Log::LOG_LEVELS::LDEBUG:
logLevel = ANDROID_LOG_DEBUG;
break;
case LogTypes::LOG_LEVELS::LINFO:
case Common::Log::LOG_LEVELS::LINFO:
logLevel = ANDROID_LOG_INFO;
break;
case LogTypes::LOG_LEVELS::LWARNING:
case Common::Log::LOG_LEVELS::LWARNING:
logLevel = ANDROID_LOG_WARN;
break;
case LogTypes::LOG_LEVELS::LERROR:
case Common::Log::LOG_LEVELS::LERROR:
logLevel = ANDROID_LOG_ERROR;
break;
case LogTypes::LOG_LEVELS::LNOTICE:
case Common::Log::LOG_LEVELS::LNOTICE:
logLevel = ANDROID_LOG_INFO;
break;
}
@@ -22,7 +22,7 @@ ConsoleListener::~ConsoleListener()
fflush(nullptr);
}

void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
void ConsoleListener::Log(Common::Log::LOG_LEVELS level, const char* text)
{
char color_attr[16] = "";
char reset_attr[16] = "";
@@ -32,15 +32,15 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
strcpy(reset_attr, "\x1b[0m");
switch (level)
{
case LogTypes::LOG_LEVELS::LNOTICE:
case Common::Log::LOG_LEVELS::LNOTICE:
// light green
strcpy(color_attr, "\x1b[92m");
break;
case LogTypes::LOG_LEVELS::LERROR:
case Common::Log::LOG_LEVELS::LERROR:
// light red
strcpy(color_attr, "\x1b[91m");
break;
case LogTypes::LOG_LEVELS::LWARNING:
case Common::Log::LOG_LEVELS::LWARNING:
// light yellow
strcpy(color_attr, "\x1b[93m");
break;
@@ -15,7 +15,7 @@ ConsoleListener::~ConsoleListener()
{
}

void ConsoleListener::Log(LogTypes::LOG_LEVELS level, const char* text)
void ConsoleListener::Log([[maybe_unused]] Common::Log::LOG_LEVELS level, const char* text)
{
::OutputDebugStringW(UTF8ToUTF16(text).c_str());
}
@@ -4,7 +4,7 @@

#pragma once

namespace LogTypes
namespace Common::Log
{
enum LOG_TYPE
{
@@ -72,20 +72,19 @@ enum LOG_LEVELS

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, ...)
void GenericLog(Common::Log::LOG_LEVELS level, Common::Log::LOG_TYPE type, const char* file,
int line, const char* fmt, ...)
#ifdef __GNUC__
__attribute__((format(printf, 5, 6)))
#endif
;
} // namespace Common::Log

#if defined(_DEBUG) || defined(DEBUGFAST)
#define MAX_LOGLEVEL LogTypes::LOG_LEVELS::LDEBUG
#define MAX_LOGLEVEL Common::Log::LOG_LEVELS::LDEBUG
#else
#ifndef MAX_LOGLEVEL
#define MAX_LOGLEVEL LogTypes::LOG_LEVELS::LINFO
#define MAX_LOGLEVEL Common::Log::LOG_LEVELS::LINFO
#endif // loglevel
#endif // logging

@@ -94,31 +93,31 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char*
do \
{ \
if (v <= MAX_LOGLEVEL) \
GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
Common::Log::GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \
} while (0)

#define ERROR_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LERROR, __VA_ARGS__); \
GENERIC_LOG(Common::Log::t, Common::Log::LERROR, __VA_ARGS__); \
} while (0)
#define WARN_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LWARNING, __VA_ARGS__); \
GENERIC_LOG(Common::Log::t, Common::Log::LWARNING, __VA_ARGS__); \
} while (0)
#define NOTICE_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LNOTICE, __VA_ARGS__); \
GENERIC_LOG(Common::Log::t, Common::Log::LNOTICE, __VA_ARGS__); \
} while (0)
#define INFO_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LINFO, __VA_ARGS__); \
GENERIC_LOG(Common::Log::t, Common::Log::LINFO, __VA_ARGS__); \
} while (0)
#define DEBUG_LOG(t, ...) \
do \
{ \
GENERIC_LOG(LogTypes::t, LogTypes::LDEBUG, __VA_ARGS__); \
GENERIC_LOG(Common::Log::t, Common::Log::LDEBUG, __VA_ARGS__); \
} while (0)

0 comments on commit c792961

Please sign in to comment.
You can’t perform that action at this time.