mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-01 15:46:37 +00:00
Revert "Remove format lib all together it was a relic of spdlog anyway"
This reverts commit 487dccfddd.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#ifndef EQEMU_LOGSYS_H
|
||||
#define EQEMU_LOGSYS_H
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
@@ -157,6 +158,13 @@ public:
|
||||
void SetCurrentTimeStamp(char* time_stamp); /* Used in file logs to prepend a timestamp entry for logs */
|
||||
void StartFileLogs(const std::string &log_name = ""); /* Used to declare the processes file log and to keep it open for later use */
|
||||
|
||||
template <typename... Args>
|
||||
void OutF(Logs::DebugLevel debug_level, uint16 log_category, const char *fmt, const Args&... args)
|
||||
{
|
||||
std::string log_str = fmt::format(fmt, args...);
|
||||
Out(debug_level, log_category, log_str);
|
||||
}
|
||||
|
||||
/*
|
||||
LogSettings Struct
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ void EQ::Net::DaybreakConnectionManager::ProcessResend()
|
||||
void EQ::Net::DaybreakConnectionManager::ProcessPacket(const std::string &endpoint, int port, const char *data, size_t size)
|
||||
{
|
||||
if (size < DaybreakHeader::size()) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, "Packet of size %u which is less than %u", size, DaybreakHeader::size());
|
||||
Log.OutF(Logs::Detail, Logs::Netcode, "Packet of size {0} which is less than {1}", size, DaybreakHeader::size());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void EQ::Net::DaybreakConnectionManager::ProcessPacket(const std::string &endpoi
|
||||
}
|
||||
}
|
||||
catch (std::exception &ex) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, "Error processing packet: %s", ex.what());
|
||||
Log.OutF(Logs::Detail, Logs::Netcode, "Error processing packet: {0}", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ void EQ::Net::DaybreakConnection::ProcessPacket(Packet &p)
|
||||
}
|
||||
|
||||
if (p.GetInt8(0) != 0) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, "Error parsing packet, did not start with a 0 frame, not a valid protocol packet.");
|
||||
Log.OutF(Logs::Detail, Logs::Netcode, "Error parsing packet, did not start with a 0 frame, not a valid protocol packet.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ void EQ::Net::DaybreakConnection::ProcessPacket(Packet &p)
|
||||
|
||||
if (PacketCanBeEncoded(p)) {
|
||||
if (!ValidateCRC(p)) {
|
||||
Log.Out(Logs::Detail, Logs::Netcode, "Tossed packet that failed CRC of type 0x%x", p.Length() >= 2 ? p.GetInt8(1) : 0);
|
||||
Log.OutF(Logs::Detail, Logs::Netcode, "Tossed packet that failed CRC of type {0:#x}", p.Length() >= 2 ? p.GetInt8(1) : 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -664,7 +664,7 @@ void EQ::Net::DaybreakConnection::ProcessDecodedPacket(Packet &p)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Log.Out(Logs::Detail, Logs::Netcode, "Unhandled opcode 0x%x", p.GetInt8(1));
|
||||
Log.OutF(Logs::Detail, Logs::Netcode, "Unhandled opcode {0:#x}", p.GetInt8(1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void EQ::Net::EQStreamManager::DaybreakPacketRecv(std::shared_ptr<DaybreakConnec
|
||||
if (match == EQ::Patches::IdentityMatchSuccess) {
|
||||
iter->second->RegisterPatch(pt.get());
|
||||
patch = pt.get();
|
||||
Log.Out(Logs::General, Logs::Debug, "Identified patch with name %s", pt->GetName().c_str());
|
||||
Log.OutF(Logs::General, Logs::Debug, "Identified patch with name {0}", pt->GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void EQ::Net::EQStreamManager::DaybreakPacketRecv(std::shared_ptr<DaybreakConnec
|
||||
patch->Decode(&p, opcode, out);
|
||||
|
||||
if (opcode == OP_Unknown) {
|
||||
Log.Out(Logs::General, Logs::Netcode, "Incoming packet was not handled because the opcode was not found.\n%s", p.ToString().c_str());
|
||||
Log.OutF(Logs::General, Logs::Netcode, "Incoming packet was not handled because the opcode was not found.\n{0}", p.ToString());
|
||||
}
|
||||
else {
|
||||
if (m_on_packet_recv) {
|
||||
@@ -68,7 +68,7 @@ void EQ::Net::EQStreamManager::DaybreakPacketRecv(std::shared_ptr<DaybreakConnec
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::General, Logs::Netcode, "Incoming packet was not handled because we don't have a patch set.\n%s", p.ToString().c_str());
|
||||
Log.OutF(Logs::General, Logs::Netcode, "Incoming packet was not handled because we don't have a patch set.\n{0}", p.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "packet.h"
|
||||
#include <net/endian.h>
|
||||
#include <string_util.h>
|
||||
#include <fmt/format.h>
|
||||
#include <cctype>
|
||||
|
||||
void EQ::Net::Packet::PutInt8(size_t offset, int8_t value)
|
||||
@@ -290,12 +290,12 @@ std::string EQ::Net::Packet::ToString(size_t line_length) const
|
||||
char *data = (char*)Data();
|
||||
|
||||
for (i = 0; i < lines; ++i) {
|
||||
ret += StringFormat("%.5x |", i * line_length);
|
||||
ret += fmt::format("{:0>5x} |", i * line_length);
|
||||
std::string hex;
|
||||
std::string ascii;
|
||||
for (size_t j = 0; j < line_length; ++j) {
|
||||
hex += StringFormat(" %.2x", (uint8_t)data[(i * line_length) + j]);
|
||||
ascii += StringFormat("%c", ToSafePrint(data[(i * line_length) + j]));
|
||||
hex += fmt::format(" {:0>2x}", (uint8_t)data[(i * line_length) + j]);
|
||||
ascii += fmt::format("{}", ToSafePrint(data[(i * line_length) + j]));
|
||||
}
|
||||
|
||||
ret += hex;
|
||||
@@ -305,7 +305,7 @@ std::string EQ::Net::Packet::ToString(size_t line_length) const
|
||||
}
|
||||
|
||||
if (Length() % line_length > 0) {
|
||||
ret += StringFormat("%.5x |", i * line_length);
|
||||
ret += fmt::format("{:0>5x} |", i * line_length);
|
||||
|
||||
size_t non_blank_count = Length() % line_length;
|
||||
size_t blank_count = line_length - non_blank_count;
|
||||
@@ -313,8 +313,8 @@ std::string EQ::Net::Packet::ToString(size_t line_length) const
|
||||
std::string ascii;
|
||||
|
||||
for (size_t j = 0; j < non_blank_count; ++j) {
|
||||
hex += StringFormat(" %.2x", (uint8_t)data[(i * line_length) + j]);
|
||||
ascii += StringFormat("%x", ToSafePrint(data[(i * line_length) + j]));
|
||||
hex += fmt::format(" {:0>2x}", (uint8_t)data[(i * line_length) + j]);
|
||||
ascii += fmt::format("{}", ToSafePrint(data[(i * line_length) + j]));
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < blank_count; ++j) {
|
||||
|
||||
Reference in New Issue
Block a user