More moving around of internal EQEmuLogSys functions

This commit is contained in:
Akkadius 2015-01-14 05:12:01 -06:00
parent 99a0012bdd
commit bdd170df6c
3 changed files with 81 additions and 78 deletions

View File

@ -18,8 +18,8 @@
#include "eqemu_logsys.h"
#include "string_util.h"
#include "platform.h"
#include "string_util.h"
#include <iostream>
#include <fstream>
@ -126,15 +126,6 @@ void EQEmuLogSys::LoadLogSettings()
log_settings_loaded = true;
}
void EQEmuLogSys::StartLogs(const std::string log_name)
{
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone){
std::cout << "Starting Zone Logs..." << std::endl;
EQEmuLogSys::MakeDirectory("logs/zone");
process_log.open(StringFormat("logs/zone/%s.txt", log_name.c_str()), std::ios_base::app | std::ios_base::out);
}
}
std::string EQEmuLogSys::FormatDebugCategoryMessageString(uint16 log_category, std::string in_message){
std::string category_string = "";
if (log_category > 0 && LogCategoryName[log_category]){
@ -143,20 +134,7 @@ std::string EQEmuLogSys::FormatDebugCategoryMessageString(uint16 log_category, s
return StringFormat("%s%s", category_string.c_str(), in_message.c_str());
}
void EQEmuLogSys::LogDebugType(DebugLevel debug_level, uint16 log_category, std::string message, ...)
{
va_list args;
va_start(args, message);
std::string output_message = vStringFormat(message.c_str(), args);
va_end(args);
std::string output_debug_message = EQEmuLogSys::FormatDebugCategoryMessageString(log_category, output_message);
EQEmuLogSys::ProcessGMSay(EQEmuLogSys::Debug, output_debug_message);
EQEmuLogSys::ConsoleMessage(EQEmuLogSys::Debug, output_debug_message);
EQEmuLogSys::ProcessLogWrite(EQEmuLogSys::Debug, output_debug_message);
}
void EQEmuLogSys::ProcessGMSay(uint16 log_type, std::string message){
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone){
@ -176,51 +154,7 @@ void EQEmuLogSys::ProcessLogWrite(uint16 log_type, std::string message){
}
}
void EQEmuLogSys::LogDebug(DebugLevel debug_level, std::string message, ...)
{
va_list args;
va_start(args, message);
std::string output_message = vStringFormat(message.c_str(), args);
va_end(args);
EQEmuLogSys::ProcessGMSay(EQEmuLogSys::Debug, output_message);
EQEmuLogSys::ConsoleMessage(EQEmuLogSys::Debug, output_message);
EQEmuLogSys::ProcessLogWrite(EQEmuLogSys::Debug, output_message);
}
void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp){
time_t raw_time;
struct tm * time_info;
time(&raw_time);
time_info = localtime(&raw_time);
strftime(time_stamp, 80, "[%d-%m-%Y :: %H:%M:%S]", time_info);
}
void EQEmuLogSys::MakeDirectory(std::string directory_name){
#ifdef _WINDOWS
_mkdir(directory_name.c_str());
#else
mkdir(directory_name.c_str());
#endif
}
void EQEmuLogSys::Log(uint16 log_type, const std::string message, ...)
{
if (log_type > EQEmuLogSys::MaxLogID){
return;
}
va_list args;
va_start(args, message);
std::string output_message = vStringFormat(message.c_str(), args);
va_end(args);
EQEmuLogSys::ProcessGMSay(log_type, output_message);
EQEmuLogSys::ConsoleMessage(log_type, output_message);
EQEmuLogSys::ProcessLogWrite(log_type, output_message);
}
void EQEmuLogSys::ConsoleMessage(uint16 log_type, const std::string message)
void EQEmuLogSys::ProcessConsoleMessage(uint16 log_type, const std::string message)
{
if (log_type > EQEmuLogSys::MaxLogID){
return;
@ -251,10 +185,77 @@ void EQEmuLogSys::ConsoleMessage(uint16 log_type, const std::string message)
#endif
}
void EQEmuLogSys::CloseZoneLogs()
void EQEmuLogSys::LogDebugType(DebugLevel debug_level, uint16 log_category, std::string message, ...)
{
va_list args;
va_start(args, message);
std::string output_message = vStringFormat(message.c_str(), args);
va_end(args);
std::string output_debug_message = EQEmuLogSys::FormatDebugCategoryMessageString(log_category, output_message);
EQEmuLogSys::ProcessConsoleMessage(EQEmuLogSys::Debug, output_debug_message);
EQEmuLogSys::ProcessGMSay(EQEmuLogSys::Debug, output_debug_message);
EQEmuLogSys::ProcessLogWrite(EQEmuLogSys::Debug, output_debug_message);
}
void EQEmuLogSys::LogDebug(DebugLevel debug_level, std::string message, ...)
{
va_list args;
va_start(args, message);
std::string output_message = vStringFormat(message.c_str(), args);
va_end(args);
EQEmuLogSys::ProcessConsoleMessage(EQEmuLogSys::Debug, output_message);
EQEmuLogSys::ProcessGMSay(EQEmuLogSys::Debug, output_message);
EQEmuLogSys::ProcessLogWrite(EQEmuLogSys::Debug, output_message);
}
void EQEmuLogSys::Log(uint16 log_type, const std::string message, ...)
{
if (log_type > EQEmuLogSys::MaxLogID){
return;
}
va_list args;
va_start(args, message);
std::string output_message = vStringFormat(message.c_str(), args);
va_end(args);
EQEmuLogSys::ProcessConsoleMessage(log_type, output_message);
EQEmuLogSys::ProcessGMSay(log_type, output_message);
EQEmuLogSys::ProcessLogWrite(log_type, output_message);
}
void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp){
time_t raw_time;
struct tm * time_info;
time(&raw_time);
time_info = localtime(&raw_time);
strftime(time_stamp, 80, "[%d-%m-%Y :: %H:%M:%S]", time_info);
}
void EQEmuLogSys::MakeDirectory(std::string directory_name){
#ifdef _WINDOWS
_mkdir(directory_name.c_str());
#else
mkdir(directory_name.c_str());
#endif
}
void EQEmuLogSys::CloseFileLogs()
{
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone){
std::cout << "Closing down zone logs..." << std::endl;
process_log.close();
}
}
void EQEmuLogSys::StartFileLogs(const std::string log_name)
{
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone){
std::cout << "Starting Zone Logs..." << std::endl;
EQEmuLogSys::MakeDirectory("logs/zone");
process_log.open(StringFormat("logs/zone/%s.txt", log_name.c_str()), std::ios_base::app | std::ios_base::out);
}
}

View File

@ -73,15 +73,15 @@ public:
MaxCategoryID /* Don't Remove this*/
};
void CloseZoneLogs();
void ConsoleMessage(uint16 log_type, const std::string message);
void CloseFileLogs();
void LoadLogSettings();
void Log(uint16 log_type, const std::string message, ...);
void LogDebug(DebugLevel debug_level, std::string message, ...);
void LogDebugType(DebugLevel debug_level, uint16 log_category, std::string message, ...);
void MakeDirectory(std::string directory_name);
void SetCurrentTimeStamp(char* time_stamp);
void StartLogs(const std::string log_name);
void StartFileLogs(const std::string log_name);
struct LogSettings{
uint8 log_to_file;
@ -99,9 +99,11 @@ private:
bool zone_general_init = false;
std::function<void(uint16 log_type, std::string&)> on_log_gmsay_hook;
std::string FormatDebugCategoryMessageString(uint16 log_category, std::string in_message);
void ProcessConsoleMessage(uint16 log_type, const std::string message);
void ProcessGMSay(uint16 log_type, std::string message);
void ProcessLogWrite(uint16 log_type, std::string message);
std::string FormatDebugCategoryMessageString(uint16 log_category, std::string in_message);
};
extern EQEmuLogSys logger;

View File

@ -152,7 +152,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
/* Set Logging */
logger.StartLogs(StringFormat("%s_ver-%u_instid-%u_port-%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort));
logger.StartFileLogs(StringFormat("%s_ver-%u_instid-%u_port-%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort));
return true;
}
@ -720,7 +720,7 @@ void Zone::Shutdown(bool quite)
parse->ReloadQuests(true);
UpdateWindowTitle();
logger.CloseZoneLogs();
logger.CloseFileLogs();
}
void Zone::LoadZoneDoors(const char* zone, int16 version)