Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
PacketLog.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Opcodes.h"
7#include "PacketLog.h"
8#include "WorldPacket.h"
9
10namespace
11{
12Skyfire::PacketLogServerDirection ToPacketLogServerDirection(Direction direction)
13{
15}
16}
17
22
26
28{
29 sPacketLogServer->Initialize("packetlogserver.active", "PacketLogs");
30}
31
33{
34 return sPacketLogServer->CanLogPacket();
35}
36
37void PacketLog::LogPacket(WorldPacket const& packet, Direction direction)
38{
39 uint32 opcode = direction == CLIENT_TO_SERVER ? const_cast<WorldPacket&>(packet).GetReceivedOpcode() : serverOpcodeTable[packet.GetOpcode()]->OpcodeNumber;
40 sPacketLogServer->LogBinaryPacket(ToPacketLogServerDirection(direction), opcode,
41 packet.size() ? packet.contents() : NULL, packet.size());
42}
43
45{
46 sPacketLogServer->EnableGlobalLogging();
47}
48
50{
51 sPacketLogServer->DisableAllLogging();
52}
53
54void PacketLog::EnableCharacterLogging(std::string const& characterName)
55{
56 sPacketLogServer->EnableCharacterLogging(characterName);
57}
58
59void PacketLog::DisableCharacterLogging(std::string const& characterName)
60{
61 sPacketLogServer->DisableCharacterLogging(characterName);
62}
63
65{
66 return sPacketLogServer->IsGlobalLoggingEnabled();
67}
68
70{
71 return sPacketLogServer->GetCharacterLoggingCount();
72}
73
74void PacketLog::LogPacket(void const* sessionKey, PacketLogSessionInfo const& sessionInfo, WorldPacket const& packet, Direction direction)
75{
76 LogPacket(packet, direction);
77
78 uint32 opcode = direction == CLIENT_TO_SERVER ? const_cast<WorldPacket&>(packet).GetReceivedOpcode() : serverOpcodeTable[packet.GetOpcode()]->OpcodeNumber;
79 std::string opcodeName = GetOpcodeNameForLogging(packet.GetOpcode(), direction == SERVER_TO_CLIENT);
80 sPacketLogServer->LogPacket(sessionKey, sessionInfo, ToPacketLogServerDirection(direction), opcode, opcodeName,
81 packet.size() ? packet.contents() : NULL, packet.size());
82}
83
84void PacketLog::LogMarker(void const* sessionKey, PacketLogSessionInfo const& sessionInfo, std::string const& marker)
85{
86 sPacketLogServer->LogMarker(sessionKey, sessionInfo, marker);
87}
88
89void PacketLog::RefreshSessionInfo(void const* sessionKey, PacketLogSessionInfo const& sessionInfo)
90{
91 sPacketLogServer->RefreshSessionInfo(sessionKey, sessionInfo);
92}
93
94void PacketLog::CloseSession(void const* sessionKey)
95{
96 sPacketLogServer->CloseSession(sessionKey);
97}
std::uint32_t uint32
Definition Define.h:77
Skyfire::PacketLogServerSessionInfo PacketLogSessionInfo
Definition PacketLog.h:21
Direction
Definition PacketLog.h:14
@ SERVER_TO_CLIENT
Definition PacketLog.h:16
@ CLIENT_TO_SERVER
Definition PacketLog.h:15
#define sPacketLogServer
size_t size() const
Definition ByteBuffer.h:609
uint8 * contents()
Definition ByteBuffer.h:605
void LogPacket(WorldPacket const &packet, Direction direction)
Definition PacketLog.cpp:37
void DisableCharacterLogging(std::string const &characterName)
Definition PacketLog.cpp:59
void RefreshSessionInfo(void const *sessionKey, PacketLogSessionInfo const &sessionInfo)
Definition PacketLog.cpp:89
bool CanLogPacket() const
Definition PacketLog.cpp:32
void CloseSession(void const *sessionKey)
Definition PacketLog.cpp:94
size_t GetCharacterLoggingCount() const
Definition PacketLog.cpp:69
void EnableGlobalLogging()
Definition PacketLog.cpp:44
void EnableCharacterLogging(std::string const &characterName)
Definition PacketLog.cpp:54
bool IsGlobalLoggingEnabled() const
Definition PacketLog.cpp:64
void LogMarker(void const *sessionKey, PacketLogSessionInfo const &sessionInfo, std::string const &marker)
Definition PacketLog.cpp:84
void DisableAllLogging()
Definition PacketLog.cpp:49
void Initialize()
Definition PacketLog.cpp:27
Opcodes GetOpcode() const
Definition WorldPacket.h:38
std::string GetOpcodeNameForLogging(Opcodes id, bool isServerOpcode, uint16 opcodeNumber=0)
Lookup opcode name for human understandable logging.
Definition Opcodes.h:1157
OpcodeTable serverOpcodeTable
Definition Opcodes.cpp:9
@ PACKET_LOG_SERVER_TO_CLIENT
@ PACKET_LOG_CLIENT_TO_SERVER