|
|
@@ -5,37 +5,32 @@
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
-#if CROWN_DEBUG
|
|
|
-
|
|
|
-#include "console_server.h"
|
|
|
-#include "string_utils.h"
|
|
|
-#include "os.h"
|
|
|
+#include "config.h"
|
|
|
+#include <cstdarg>
|
|
|
|
|
|
namespace crown
|
|
|
{
|
|
|
-namespace log_internal
|
|
|
+
|
|
|
+/// Enumerates log levels.
|
|
|
+struct LogSeverity
|
|
|
{
|
|
|
- inline void logx(LogSeverity::Enum sev, const char* msg, va_list args)
|
|
|
+ enum Enum
|
|
|
{
|
|
|
- char buf[2048];
|
|
|
- int len = vsnprintf(buf, sizeof(buf), msg, args);
|
|
|
- if (len > (int)sizeof(buf))
|
|
|
- len = sizeof(buf) - 1;
|
|
|
-
|
|
|
- buf[len] = '\0';
|
|
|
- console_server_globals::console().log(buf, sev);
|
|
|
- os::log(buf);
|
|
|
- }
|
|
|
+ INFO = 0,
|
|
|
+ WARN = 1,
|
|
|
+ ERROR = 2,
|
|
|
+ DEBUG = 3
|
|
|
+ };
|
|
|
+};
|
|
|
|
|
|
- inline void logx(LogSeverity::Enum sev, const char* msg, ...)
|
|
|
- {
|
|
|
- va_list args;
|
|
|
- va_start(args, msg);
|
|
|
- logx(sev, msg, args);
|
|
|
- va_end(args);
|
|
|
- }
|
|
|
+namespace log_internal
|
|
|
+{
|
|
|
+ void logx(LogSeverity::Enum sev, const char* msg, va_list args);
|
|
|
+ void logx(LogSeverity::Enum sev, const char* msg, ...);
|
|
|
} // namespace log_internal
|
|
|
} // namespace crown
|
|
|
+
|
|
|
+#if CROWN_DEBUG
|
|
|
#define CE_LOGI(msg, ...) crown::log_internal::logx(crown::LogSeverity::INFO, msg, ##__VA_ARGS__)
|
|
|
#define CE_LOGD(msg, ...) crown::log_internal::logx(crown::LogSeverity::DEBUG, msg, ##__VA_ARGS__)
|
|
|
#define CE_LOGE(msg, ...) crown::log_internal::logx(crown::LogSeverity::ERROR, msg, ##__VA_ARGS__)
|