Remove text file logging
This commit is contained in:
parent
24912eeffd
commit
1715621aa5
|
|
@ -5,7 +5,7 @@
|
|||
#include "Util.h"
|
||||
#include "LUrlParser.h"
|
||||
#ifdef ARBITERBUILD
|
||||
#include "Logger.h"
|
||||
// #include "Logger.h"
|
||||
#endif
|
||||
|
||||
static bool hasJobId = false;
|
||||
|
|
|
|||
|
|
@ -1,80 +0,0 @@
|
|||
#include "pch.h"
|
||||
#include "Logger.h"
|
||||
|
||||
//#pragma warning(disable : 4996)
|
||||
|
||||
HANDLE Logger::handle;
|
||||
std::ofstream Logger::outputLog;
|
||||
std::ofstream Logger::httpLog;
|
||||
|
||||
void Logger::Initialize(const std::string jobId)
|
||||
{
|
||||
AllocConsole();
|
||||
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
|
||||
Logger::handle = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, Logger::handle);
|
||||
|
||||
#ifndef NDEBUG
|
||||
printf("[[[ DLL COMPILED AS DEBUG ]]]\n");
|
||||
#endif
|
||||
|
||||
// lol
|
||||
// printf("Access key read: \n");
|
||||
// printf("Current Access key: \n");
|
||||
// printf("Service starting...\n");
|
||||
// printf("Intializing Roblox Web Service\n");
|
||||
// printf("Service Started on port 64989\n");
|
||||
|
||||
Logger::outputLog = std::ofstream(jobId + std::string("-Output.txt"));
|
||||
Logger::httpLog = std::ofstream(jobId + std::string("-Http.txt"));
|
||||
}
|
||||
|
||||
void Logger::Log(LogType type, const std::string message)
|
||||
{
|
||||
if (!handle) return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case LogType::Output:
|
||||
outputLog << "[" << Logger::UtcTime() << "] " << message.c_str() << std::endl;
|
||||
break;
|
||||
case LogType::Http:
|
||||
httpLog << "[" << Logger::UtcTime() << "] " << message.c_str() << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Print(int type, const std::string message)
|
||||
{
|
||||
if (!Logger::handle) return;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 1: // RBX::MESSAGE_OUTPUT:
|
||||
Logger::Log(LogType::Output, std::string("[MESSAGE_OUTPUT] ") + message);
|
||||
SetConsoleTextAttribute(Logger::handle, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
|
||||
break;
|
||||
case 0: // RBX::MESSAGE_INFO:
|
||||
Logger::Log(LogType::Output, std::string("[MESSAGE_INFO] ") + message);
|
||||
SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
break;
|
||||
case 2: // RBX::MESSAGE_WARNING:
|
||||
Logger::Log(LogType::Output, std::string("[MESSAGE_WARNING] ") + message);
|
||||
SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN);
|
||||
break;
|
||||
case 3: // RBX::MESSAGE_ERROR:
|
||||
Logger::Log(LogType::Output, std::string("[MESSAGE_ERROR] ") + message);
|
||||
SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_INTENSITY);
|
||||
break;
|
||||
}
|
||||
printf("%s\n", message.c_str());
|
||||
SetConsoleTextAttribute(Logger::handle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
}
|
||||
|
||||
std::string Logger::UtcTime()
|
||||
{
|
||||
std::stringstream time;
|
||||
std::time_t now = std::time(NULL);
|
||||
// time << std::put_time(std::localtime(&now), "%F %T");
|
||||
return time.str();
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
enum class LogType { Output, Http };
|
||||
|
||||
class Logger
|
||||
{
|
||||
private:
|
||||
static std::ofstream outputLog;
|
||||
static std::ofstream httpLog;
|
||||
public:
|
||||
static HANDLE handle;
|
||||
static void Initialize(const std::string jobId);
|
||||
static void Log(LogType type, const std::string message);
|
||||
static void Print(int type, const std::string message);
|
||||
static std::string UtcTime();
|
||||
};
|
||||
|
|
@ -166,7 +166,6 @@
|
|||
<ClInclude Include="RCCOutput.h" />
|
||||
<ClInclude Include="ReplicatorSecurity.h" />
|
||||
<ClInclude Include="TrustCheck.h" />
|
||||
<ClInclude Include="Logger.h" />
|
||||
<ClInclude Include="LUrlParser.h" />
|
||||
<ClInclude Include="Patches.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
|
|
@ -178,7 +177,6 @@
|
|||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="MFCCommandLine.cpp" />
|
||||
<ClCompile Include="Logger.cpp" />
|
||||
<ClCompile Include="LUrlParser.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@
|
|||
<ClInclude Include="LUrlParser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Logger.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Util.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -80,9 +77,6 @@
|
|||
<ClCompile Include="LUrlParser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Logger.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,26 @@
|
|||
#include "pch.h"
|
||||
#include "RCCOutput.h"
|
||||
#include "Logger.h"
|
||||
|
||||
HANDLE outputHandle;
|
||||
|
||||
void InitializeOutput()
|
||||
{
|
||||
AllocConsole();
|
||||
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
|
||||
outputHandle = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
SetStdHandle(STD_OUTPUT_HANDLE, outputHandle);
|
||||
|
||||
#ifndef NDEBUG
|
||||
printf("[[[ DLL COMPILED AS DEBUG ]]]\n");
|
||||
#endif
|
||||
|
||||
// lol
|
||||
// printf("Access key read: \n");
|
||||
// printf("Current Access key: \n");
|
||||
// printf("Service starting...\n");
|
||||
// printf("Intializing Roblox Web Service\n");
|
||||
// printf("Service Started on port 64989\n");
|
||||
}
|
||||
|
||||
StandardOut__print_t StandardOut__print = (StandardOut__print_t)ADDRESS_STANDARDOUT__PRINT;
|
||||
|
||||
|
|
@ -8,14 +28,27 @@ void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string*
|
|||
{
|
||||
StandardOut__print(_this, type, message);
|
||||
|
||||
if (Logger::handle)
|
||||
{
|
||||
#ifdef NDEBUG
|
||||
// i have absolutely no clue why but the location of the message pointer is offset 4 bytes when the dll compiled as release
|
||||
int messagePtr = (int)message + 4;
|
||||
std::string* message = reinterpret_cast<std::string*>(messagePtr);
|
||||
// i have absolutely no clue why but the location of the message pointer is offset 4 bytes when the dll compiled as release
|
||||
int messagePtr = (int)message + 4;
|
||||
message = reinterpret_cast<std::string*>(messagePtr);
|
||||
#endif
|
||||
|
||||
Logger::Print(type, *message);
|
||||
switch (type)
|
||||
{
|
||||
case 1: // RBX::MESSAGE_OUTPUT:
|
||||
SetConsoleTextAttribute(outputHandle, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
|
||||
break;
|
||||
case 0: // RBX::MESSAGE_INFO:
|
||||
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
break;
|
||||
case 2: // RBX::MESSAGE_WARNING:
|
||||
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN);
|
||||
break;
|
||||
case 3: // RBX::MESSAGE_ERROR:
|
||||
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_INTENSITY);
|
||||
break;
|
||||
}
|
||||
printf("%s\n", message->c_str());
|
||||
SetConsoleTextAttribute(outputHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "Classes.h"
|
||||
|
||||
void InitializeOutput();
|
||||
|
||||
typedef void(__thiscall* StandardOut__print_t)(int _this, int type, std::string* message);
|
||||
void __fastcall StandardOut__print_hook(int _this, void*, int type, std::string* message);
|
||||
extern StandardOut__print_t StandardOut__print;
|
||||
|
|
@ -62,6 +62,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||
{
|
||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
#ifdef ARBITERBUILD
|
||||
InitializeOutput();
|
||||
#endif
|
||||
|
||||
LONG error = Patches::Apply();
|
||||
if (error != NO_ERROR)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue