mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-05 19:32:25 +00:00
Backport logging from debug.cpp EQEmuLog::write back to EQEmuLogSys::WriteZoneLog
Logs being written to logs/zone/ currently
This commit is contained in:
parent
80d11d4ca9
commit
2aacc7323e
@ -44,6 +44,10 @@ namespace ConsoleColor {
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "misc_functions.h"
|
#include "misc_functions.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
#include "eqemu_logsys.h"
|
||||||
|
#include "string_util.h"
|
||||||
|
|
||||||
|
EQEmuLogSys backport_log_sys;
|
||||||
|
|
||||||
#ifndef va_copy
|
#ifndef va_copy
|
||||||
#define va_copy(d,s) ((d) = (s))
|
#define va_copy(d,s) ((d) = (s))
|
||||||
@ -145,6 +149,7 @@ bool EQEmuLog::write(LogIDs id, const char *fmt, ...)
|
|||||||
if (id >= MaxLogID) {
|
if (id >= MaxLogID) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dofile = false;
|
bool dofile = false;
|
||||||
if (pLogStatus[id] & 1) {
|
if (pLogStatus[id] & 1) {
|
||||||
dofile = open(id);
|
dofile = open(id);
|
||||||
@ -156,82 +161,17 @@ bool EQEmuLog::write(LogIDs id, const char *fmt, ...)
|
|||||||
if (!logFileValid) {
|
if (!logFileValid) {
|
||||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||||
}
|
}
|
||||||
time_t aclock;
|
|
||||||
struct tm *newtime;
|
|
||||||
time( &aclock ); /* Get time in seconds */
|
|
||||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
|
||||||
if (dofile)
|
|
||||||
#ifndef NO_PIDLOG
|
|
||||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
|
||||||
#else
|
|
||||||
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
|
||||||
#endif
|
|
||||||
va_list argptr, tmpargptr;
|
va_list argptr, tmpargptr;
|
||||||
va_start(argptr, fmt);
|
va_start(argptr, fmt);
|
||||||
if (dofile) {
|
|
||||||
va_copy(tmpargptr, argptr);
|
backport_log_sys.WriteZoneLog(id, vStringFormat(fmt, argptr).c_str());
|
||||||
vfprintf( fp[id], fmt, tmpargptr );
|
|
||||||
}
|
|
||||||
if (logCallbackFmt[id]) {
|
if (logCallbackFmt[id]) {
|
||||||
msgCallbackFmt p = logCallbackFmt[id];
|
msgCallbackFmt p = logCallbackFmt[id];
|
||||||
va_copy(tmpargptr, argptr);
|
va_copy(tmpargptr, argptr);
|
||||||
p(id, fmt, tmpargptr );
|
p(id, fmt, tmpargptr );
|
||||||
}
|
}
|
||||||
if (pLogStatus[id] & 2) {
|
|
||||||
if (pLogStatus[id] & 8) {
|
|
||||||
fprintf(stderr, "[%s] ", LogNames[id]);
|
|
||||||
vfprintf( stderr, fmt, argptr );
|
|
||||||
}
|
|
||||||
/* This is what's outputted to console */
|
|
||||||
else {
|
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
HANDLE console_handle;
|
|
||||||
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
||||||
|
|
||||||
CONSOLE_FONT_INFOEX info = { 0 };
|
|
||||||
info.cbSize = sizeof(info);
|
|
||||||
info.dwFontSize.Y = 12; // leave X as zero
|
|
||||||
info.FontWeight = FW_NORMAL;
|
|
||||||
wcscpy(info.FaceName, L"Lucida Console");
|
|
||||||
SetCurrentConsoleFontEx(console_handle, NULL, &info);
|
|
||||||
|
|
||||||
if (id == EQEmuLog::LogIDs::Status){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::Yellow); }
|
|
||||||
if (id == EQEmuLog::LogIDs::Error){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightRed); }
|
|
||||||
if (id == EQEmuLog::LogIDs::Normal){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightGreen); }
|
|
||||||
if (id == EQEmuLog::LogIDs::Debug){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::Yellow); }
|
|
||||||
if (id == EQEmuLog::LogIDs::Quest){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightCyan); }
|
|
||||||
if (id == EQEmuLog::LogIDs::Commands){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightMagenta); }
|
|
||||||
if (id == EQEmuLog::LogIDs::Crash){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightRed); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stdout, "[%s] ", LogNames[id]);
|
|
||||||
vfprintf( stdout, fmt, argptr );
|
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
|
||||||
/* Always set back to white*/
|
|
||||||
SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::White);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
va_end(argptr);
|
|
||||||
if (dofile) {
|
|
||||||
fprintf(fp[id], "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Print Lind Endings */
|
|
||||||
if (pLogStatus[id] & 2) {
|
|
||||||
if (pLogStatus[id] & 8) {
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
fflush(stderr);
|
|
||||||
} else {
|
|
||||||
fprintf(stdout, "\n");
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dofile) {
|
|
||||||
fflush(fp[id]);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,6 +43,8 @@
|
|||||||
#include "../common/eqemu_exception.h"
|
#include "../common/eqemu_exception.h"
|
||||||
#include "../common/spdat.h"
|
#include "../common/spdat.h"
|
||||||
|
|
||||||
|
#include "../common/eqemu_logsys.h"
|
||||||
|
|
||||||
#include "zone_config.h"
|
#include "zone_config.h"
|
||||||
#include "masterentity.h"
|
#include "masterentity.h"
|
||||||
#include "worldserver.h"
|
#include "worldserver.h"
|
||||||
@ -69,6 +71,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#ifdef _CRTDBG_MAP_ALLOC
|
#ifdef _CRTDBG_MAP_ALLOC
|
||||||
#undef new
|
#undef new
|
||||||
@ -100,6 +103,7 @@ TitleManager title_manager;
|
|||||||
QueryServ *QServ = 0;
|
QueryServ *QServ = 0;
|
||||||
TaskManager *taskmanager = 0;
|
TaskManager *taskmanager = 0;
|
||||||
QuestParserCollection *parse = 0;
|
QuestParserCollection *parse = 0;
|
||||||
|
EQEmuLogSys log_sys;
|
||||||
|
|
||||||
const SPDat_Spell_Struct* spells;
|
const SPDat_Spell_Struct* spells;
|
||||||
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
|
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
|
||||||
@ -351,6 +355,10 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
if (!eqsf.IsOpen() && Config->ZonePort!=0) {
|
if (!eqsf.IsOpen() && Config->ZonePort!=0) {
|
||||||
_log(ZONE__INIT, "Starting EQ Network server on port %d",Config->ZonePort);
|
_log(ZONE__INIT, "Starting EQ Network server on port %d",Config->ZonePort);
|
||||||
|
|
||||||
|
// log_sys.CloseZoneLogs();
|
||||||
|
// log_sys.StartZoneLogs(StringFormat("%s_ver-%u_instid-%u_port-%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort));
|
||||||
|
|
||||||
if (!eqsf.Open(Config->ZonePort)) {
|
if (!eqsf.Open(Config->ZonePort)) {
|
||||||
_log(ZONE__INIT_ERR, "Failed to open port %d",Config->ZonePort);
|
_log(ZONE__INIT_ERR, "Failed to open port %d",Config->ZonePort);
|
||||||
ZoneConfig::SetZonePort(0);
|
ZoneConfig::SetZonePort(0);
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
#include "../common/rulesys.h"
|
#include "../common/rulesys.h"
|
||||||
#include "../common/seperator.h"
|
#include "../common/seperator.h"
|
||||||
#include "../common/string_util.h"
|
#include "../common/string_util.h"
|
||||||
|
#include "../common/eqemu_logsys.h"
|
||||||
|
|
||||||
#include "client_logs.h"
|
#include "client_logs.h"
|
||||||
#include "guild_mgr.h"
|
#include "guild_mgr.h"
|
||||||
@ -52,12 +53,18 @@
|
|||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
#include "zone_config.h"
|
#include "zone_config.h"
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <ctime>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern bool staticzone;
|
extern bool staticzone;
|
||||||
extern NetConnection net;
|
extern NetConnection net;
|
||||||
extern PetitionList petition_list;
|
extern PetitionList petition_list;
|
||||||
@ -143,6 +150,15 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
|||||||
UpdateWindowTitle();
|
UpdateWindowTitle();
|
||||||
zone->GetTimeSync();
|
zone->GetTimeSync();
|
||||||
|
|
||||||
|
/* Set Logging */
|
||||||
|
|
||||||
|
log_sys.StartZoneLogs(StringFormat("%s_ver-%u_instid-%u_port-%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort));
|
||||||
|
|
||||||
|
clock_t t = std::clock(); /* Function timer start */
|
||||||
|
uint64 i = 0;
|
||||||
|
|
||||||
|
log_sys.WriteZoneLog(1, "This is some serious shit");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -708,6 +724,8 @@ void Zone::Shutdown(bool quite)
|
|||||||
entity_list.ClearAreas();
|
entity_list.ClearAreas();
|
||||||
parse->ReloadQuests(true);
|
parse->ReloadQuests(true);
|
||||||
UpdateWindowTitle();
|
UpdateWindowTitle();
|
||||||
|
|
||||||
|
log_sys.CloseZoneLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Zone::LoadZoneDoors(const char* zone, int16 version)
|
void Zone::LoadZoneDoors(const char* zone, int16 version)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user