debug: use source_location for native logger
This commit is contained in:
@@ -6,8 +6,9 @@
|
|||||||
#include <XCEngine/Core/Containers/String.h>
|
#include <XCEngine/Core/Containers/String.h>
|
||||||
#include "../Threading/Mutex.h"
|
#include "../Threading/Mutex.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <source_location>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace XCEngine {
|
namespace XCEngine {
|
||||||
namespace Debug {
|
namespace Debug {
|
||||||
@@ -23,15 +24,36 @@ public:
|
|||||||
void RemoveSink(ILogSink* sink);
|
void RemoveSink(ILogSink* sink);
|
||||||
|
|
||||||
void Log(LogLevel level, LogCategory category,
|
void Log(LogLevel level, LogCategory category,
|
||||||
const Containers::String& message, const char* file = nullptr,
|
const Containers::String& message,
|
||||||
|
const std::source_location& location = std::source_location::current());
|
||||||
|
void Log(LogLevel level, LogCategory category,
|
||||||
|
const Containers::String& message, const char* file,
|
||||||
int32_t line = 0, const char* function = nullptr);
|
int32_t line = 0, const char* function = nullptr);
|
||||||
|
|
||||||
void Verbose(LogCategory category, const Containers::String& message);
|
void Verbose(
|
||||||
void Debug(LogCategory category, const Containers::String& message);
|
LogCategory category,
|
||||||
void Info(LogCategory category, const Containers::String& message);
|
const Containers::String& message,
|
||||||
void Warning(LogCategory category, const Containers::String& message);
|
const std::source_location& location = std::source_location::current());
|
||||||
void Error(LogCategory category, const Containers::String& message);
|
void Debug(
|
||||||
void Fatal(LogCategory category, const Containers::String& message);
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location = std::source_location::current());
|
||||||
|
void Info(
|
||||||
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location = std::source_location::current());
|
||||||
|
void Warning(
|
||||||
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location = std::source_location::current());
|
||||||
|
void Error(
|
||||||
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location = std::source_location::current());
|
||||||
|
void Fatal(
|
||||||
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location = std::source_location::current());
|
||||||
|
|
||||||
void SetMinimumLevel(LogLevel level);
|
void SetMinimumLevel(LogLevel level);
|
||||||
void SetCategoryEnabled(LogCategory category, bool enabled);
|
void SetCategoryEnabled(LogCategory category, bool enabled);
|
||||||
@@ -48,7 +70,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define XE_LOG(category, level, message) \
|
#define XE_LOG(category, level, message) \
|
||||||
XCEngine::Debug::Logger::Get().Log(level, category, message, __FILE__, __LINE__, __FUNCTION__)
|
XCEngine::Debug::Logger::Get().Log(level, category, message)
|
||||||
|
|
||||||
#define XE_ASSERT(condition, message) \
|
#define XE_ASSERT(condition, message) \
|
||||||
if (!(condition)) { \
|
if (!(condition)) { \
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
#include "TaskSystemConfig.h"
|
#include "TaskSystemConfig.h"
|
||||||
#include "Task.h"
|
#include "Task.h"
|
||||||
|
#include "LambdaTask.h"
|
||||||
#include "TaskGroup.h"
|
#include "TaskGroup.h"
|
||||||
#include "Mutex.h"
|
#include "Mutex.h"
|
||||||
#include "SpinLock.h"
|
#include "SpinLock.h"
|
||||||
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include "Debug/Logger.h"
|
#include "Debug/Logger.h"
|
||||||
#include "Debug/ConsoleLogSink.h"
|
#include "Debug/ConsoleLogSink.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <functional>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace XCEngine {
|
namespace XCEngine {
|
||||||
namespace Debug {
|
namespace Debug {
|
||||||
@@ -40,6 +42,18 @@ void Logger::RemoveSink(ILogSink* sink) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Logger::Log(LogLevel level, LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location) {
|
||||||
|
Log(
|
||||||
|
level,
|
||||||
|
category,
|
||||||
|
message,
|
||||||
|
location.file_name(),
|
||||||
|
static_cast<int32_t>(location.line()),
|
||||||
|
location.function_name());
|
||||||
|
}
|
||||||
|
|
||||||
void Logger::Log(LogLevel level, LogCategory category,
|
void Logger::Log(LogLevel level, LogCategory category,
|
||||||
const Containers::String& message, const char* file,
|
const Containers::String& message, const char* file,
|
||||||
int32_t line, const char* function) {
|
int32_t line, const char* function) {
|
||||||
@@ -73,28 +87,46 @@ void Logger::Log(LogLevel level, LogCategory category,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Verbose(LogCategory category, const Containers::String& message) {
|
void Logger::Verbose(
|
||||||
Log(LogLevel::Verbose, category, message);
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location) {
|
||||||
|
Log(LogLevel::Verbose, category, message, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Debug(LogCategory category, const Containers::String& message) {
|
void Logger::Debug(
|
||||||
Log(LogLevel::Debug, category, message);
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location) {
|
||||||
|
Log(LogLevel::Debug, category, message, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Info(LogCategory category, const Containers::String& message) {
|
void Logger::Info(
|
||||||
Log(LogLevel::Info, category, message);
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location) {
|
||||||
|
Log(LogLevel::Info, category, message, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Warning(LogCategory category, const Containers::String& message) {
|
void Logger::Warning(
|
||||||
Log(LogLevel::Warning, category, message);
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location) {
|
||||||
|
Log(LogLevel::Warning, category, message, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Error(LogCategory category, const Containers::String& message) {
|
void Logger::Error(
|
||||||
Log(LogLevel::Error, category, message);
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location) {
|
||||||
|
Log(LogLevel::Error, category, message, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::Fatal(LogCategory category, const Containers::String& message) {
|
void Logger::Fatal(
|
||||||
Log(LogLevel::Fatal, category, message);
|
LogCategory category,
|
||||||
|
const Containers::String& message,
|
||||||
|
const std::source_location& location) {
|
||||||
|
Log(LogLevel::Fatal, category, message, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Logger::SetMinimumLevel(LogLevel level) {
|
void Logger::SetMinimumLevel(LogLevel level) {
|
||||||
|
|||||||
Reference in New Issue
Block a user