aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/logging.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/logging.cpp')
-rw-r--r--NorthstarDedicatedTest/logging.cpp47
1 files changed, 20 insertions, 27 deletions
diff --git a/NorthstarDedicatedTest/logging.cpp b/NorthstarDedicatedTest/logging.cpp
index 021613d9..85b92c0c 100644
--- a/NorthstarDedicatedTest/logging.cpp
+++ b/NorthstarDedicatedTest/logging.cpp
@@ -2,33 +2,17 @@
#include "logging.h"
#include "context.h"
#include "dedicated.h"
+#include "sourceconsole.h"
#include <vector>
#include <iostream>
#include <chrono>
-std::vector<LoggingSink> loggingSinks;
-
-void Log(Context context, char* fmt, ...)
+void InitialiseLogging()
{
- va_list args;
- va_start(args, fmt);
+ AllocConsole();
+ freopen("CONOUT$", "w", stdout);
- Log(context, fmt, args);
- va_end(args);
-}
-
-void Log(Context context, char* fmt, va_list args)
-{
- char buf[1024];
- vsnprintf_s(buf, _TRUNCATE, fmt, args);
-
- for (LoggingSink& sink : loggingSinks)
- sink(context, fmt);
-}
-
-void AddLoggingSink(LoggingSink sink)
-{
- loggingSinks.push_back(sink);
+ spdlog::default_logger()->set_pattern("[%H:%M:%S] [%l] %v");
}
// default logging sink
@@ -39,14 +23,23 @@ void DefaultLoggingSink(Context context, char* message)
char timeBuf[10];
strftime(timeBuf, sizeof(timeBuf), "%X", localTime);
- std::cout << "[" << timeBuf << "] ";
- if (context != NONE)
- std::cout << "[" << GetContextName(context) << "] ";
+ std::string messageStr;
- std::cout << message;
+ messageStr.append("[");
+ messageStr.append(timeBuf);
+ messageStr.append("] ");
- if (!IsDedicated())
+ if (context != NONE)
{
-
+ messageStr.append("[");
+ messageStr.append(GetContextName(context));
+ messageStr.append("] ");
}
+
+ messageStr.append(message);
+ std::cout << messageStr;
+
+ // dont need to check dedi since this won't be initialised on dedi anyway
+ if ((*g_SourceGameConsole)->m_bInitialized)
+ (*g_SourceGameConsole)->m_pConsole->m_pConsolePanel->Print(messageStr.c_str());
} \ No newline at end of file