mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
added commands to dump the output of the consoles into a file
This commit is contained in:
parent
e2c3f744b2
commit
a5113c6740
|
@ -30,6 +30,9 @@ public:
|
||||||
str_format(aPath, sizeof(aPath), "%s/maps", m_aApplicationSavePath);
|
str_format(aPath, sizeof(aPath), "%s/maps", m_aApplicationSavePath);
|
||||||
fs_makedir(aPath);
|
fs_makedir(aPath);
|
||||||
|
|
||||||
|
str_format(aPath, sizeof(aPath), "%s/dumps", m_aApplicationSavePath);
|
||||||
|
fs_makedir(aPath);
|
||||||
|
|
||||||
str_format(aPath, sizeof(aPath), "%s/downloadedmaps", m_aApplicationSavePath);
|
str_format(aPath, sizeof(aPath), "%s/downloadedmaps", m_aApplicationSavePath);
|
||||||
fs_makedir(aPath);
|
fs_makedir(aPath);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//#include "gc_console.h"
|
//#include "gc_console.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <game/generated/client_data.h>
|
#include <game/generated/client_data.h>
|
||||||
|
|
||||||
|
@ -9,6 +10,7 @@
|
||||||
#include <engine/shared/config.h>
|
#include <engine/shared/config.h>
|
||||||
#include <engine/graphics.h>
|
#include <engine/graphics.h>
|
||||||
#include <engine/textrender.h>
|
#include <engine/textrender.h>
|
||||||
|
#include <engine/storage.h>
|
||||||
#include <engine/keys.h>
|
#include <engine/keys.h>
|
||||||
#include <engine/console.h>
|
#include <engine/console.h>
|
||||||
|
|
||||||
|
@ -570,6 +572,41 @@ void CGameConsole::Toggle(int Type)
|
||||||
m_ConsoleType = Type;
|
m_ConsoleType = Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameConsole::Dump(int Type)
|
||||||
|
{
|
||||||
|
CInstance *pConsole = Type == 1 ? &m_RemoteConsole : &m_LocalConsole;
|
||||||
|
char aFilename[128];
|
||||||
|
time_t Time;
|
||||||
|
char aDate[20];
|
||||||
|
|
||||||
|
time(&Time);
|
||||||
|
tm* TimeInfo = localtime(&Time);
|
||||||
|
strftime(aDate, sizeof(aDate), "%Y-%m-%d_%I-%M", TimeInfo);
|
||||||
|
|
||||||
|
for(int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
IOHANDLE io;
|
||||||
|
str_format(aFilename, sizeof(aFilename), "dumps/%s_dump%s-%05d.txt", Type==1?"remote_console":"local_console", aDate, i);
|
||||||
|
io = Storage()->OpenFile(aFilename, IOFLAG_WRITE);
|
||||||
|
if(io)
|
||||||
|
{
|
||||||
|
#if defined(CONF_FAMILY_WINDOWS)
|
||||||
|
static const char Newline[] = "\r\n";
|
||||||
|
#else
|
||||||
|
static const char Newline[] = "\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for(char *pEntry = pConsole->m_Backlog.First(); pEntry; pEntry = pConsole->m_Backlog.Next(pEntry))
|
||||||
|
{
|
||||||
|
io_write(io, pEntry, str_length(pEntry));
|
||||||
|
io_write(io, Newline, sizeof(Newline)-1);
|
||||||
|
}
|
||||||
|
io_close(io);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGameConsole::ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData)
|
void CGameConsole::ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
((CGameConsole *)pUserData)->Toggle(0);
|
((CGameConsole *)pUserData)->Toggle(0);
|
||||||
|
@ -590,6 +627,16 @@ void CGameConsole::ConClearRemoteConsole(IConsole::IResult *pResult, void *pUser
|
||||||
((CGameConsole *)pUserData)->m_RemoteConsole.ClearBacklog();
|
((CGameConsole *)pUserData)->m_RemoteConsole.ClearBacklog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameConsole::ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
{
|
||||||
|
((CGameConsole *)pUserData)->Dump(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameConsole::ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
{
|
||||||
|
((CGameConsole *)pUserData)->Dump(1);
|
||||||
|
}
|
||||||
|
|
||||||
void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData)
|
void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData)
|
||||||
{
|
{
|
||||||
((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr);
|
((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr);
|
||||||
|
@ -618,6 +665,8 @@ void CGameConsole::OnConsoleInit()
|
||||||
Console()->Register("toggle_remote_console", "", CFGFLAG_CLIENT, ConToggleRemoteConsole, this, "Toggle remote console");
|
Console()->Register("toggle_remote_console", "", CFGFLAG_CLIENT, ConToggleRemoteConsole, this, "Toggle remote console");
|
||||||
Console()->Register("clear_local_console", "", CFGFLAG_CLIENT, ConClearLocalConsole, this, "Clear local console");
|
Console()->Register("clear_local_console", "", CFGFLAG_CLIENT, ConClearLocalConsole, this, "Clear local console");
|
||||||
Console()->Register("clear_remote_console", "", CFGFLAG_CLIENT, ConClearRemoteConsole, this, "Clear remote console");
|
Console()->Register("clear_remote_console", "", CFGFLAG_CLIENT, ConClearRemoteConsole, this, "Clear remote console");
|
||||||
|
Console()->Register("dump_local_console", "", CFGFLAG_CLIENT, ConDumpLocalConsole, this, "Dump local console");
|
||||||
|
Console()->Register("dump_remote_console", "", CFGFLAG_CLIENT, ConDumpRemoteConsole, this, "Dump remote console");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -56,6 +56,7 @@ class CGameConsole : public CComponent
|
||||||
float m_StateChangeDuration;
|
float m_StateChangeDuration;
|
||||||
|
|
||||||
void Toggle(int Type);
|
void Toggle(int Type);
|
||||||
|
void Dump(int Type);
|
||||||
|
|
||||||
static void PossibleCommandsRenderCallback(const char *pStr, void *pUser);
|
static void PossibleCommandsRenderCallback(const char *pStr, void *pUser);
|
||||||
static void ClientConsolePrintCallback(const char *pStr, void *pUserData);
|
static void ClientConsolePrintCallback(const char *pStr, void *pUserData);
|
||||||
|
@ -63,6 +64,8 @@ class CGameConsole : public CComponent
|
||||||
static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData);
|
static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData);
|
static void ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData);
|
||||||
static void ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData);
|
static void ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
static void ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
static void ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGameConsole();
|
CGameConsole();
|
||||||
|
|
Loading…
Reference in a new issue