Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
ServerScriptLogger.cpp
Go to the documentation of this file.
1
2// =============================================================================
3// This file is adopted from rorserver at commit 4a7109ae2d9a081ccfdad8cc696dc54efe49acb3
4// Changes from the original are marked with "//RIGSOFRODS"
5// =============================================================================
6
7/*
8This file is part of "Rigs of Rods Server" (Relay mode)
9
10Copyright 2007 Pierre-Michel Ricordel
11Copyright 2014+ Rigs of Rods Community
12
13"Rigs of Rods Server" is free software: you can redistribute it
14and/or modify it under the terms of the GNU General Public License
15as published by the Free Software Foundation, either version 3
16of the License, or (at your option) any later version.
17
18"Rigs of Rods Server" is distributed in the hope that it will
19be useful, but WITHOUT ANY WARRANTY; without even the implied
20warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21See the GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with Foobar. If not, see <http://www.gnu.org/licenses/>.
25*/
26
27#ifdef USE_ANGELSCRIPT
28
29#include "ServerScriptLogger.h"
30
31#include "Application.h" // RIGSOFRODS: For App::sys_logs_dir
32#include "PlatformUtils.h" // RIGSOFRODS: For RoR::PathCombine
33
34using namespace RoR;
35
36static Ogre::Log* sServerLog = nullptr;
37
38void Init()
39{
40 if (!sServerLog)
41 sServerLog = Ogre::LogManager::getSingleton().createLog(RoR::PathCombine(App::sys_logs_dir->getStr(), "RoRServerScript.log"));
42}
43
44void Logger::Log(ServerLogLevel level, const char *format, ...)
45{
46 Init();
47
48 // Format the message
49 const int BUF_LEN = 4000; // hard limit
50 char buffer[BUF_LEN] = {}; // zeroed memory
51 va_list args;
52 va_start(args, format);
53 vsnprintf(buffer, BUF_LEN, format, args);
54 va_end(args);
55 // Log the message
56 sServerLog->logMessage(std::string(buffer));
57}
58
59void Logger::Log(ServerLogLevel level, std::string const& msg)
60{
61 Init();
62
63 sServerLog->logMessage(msg);
64}
65
66#endif // USE_ANGELSCRIPT
Central state/object manager and communications hub.
Platform-specific utilities. We use narrow UTF-8 encoded strings as paths. Inspired by http://utf8eve...
static Ogre::Log * sServerLog
void Init()
ServerLogLevel
std::string PathCombine(std::string a, std::string b)
void Log(ServerLogLevel level, const char *format,...)
CVar * sys_logs_dir