Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
PacketLogServer.h
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#ifndef SKYFIRE_PACKETLOGSERVER_H
7#define SKYFIRE_PACKETLOGSERVER_H
8
9#include "Common.h"
10#include "Platform/Singleton.h"
11#include <cstddef>
12#include <cstdio>
13#include <mutex>
14#include <string>
15#include <unordered_map>
16#include <unordered_set>
17#include <vector>
18
19namespace Skyfire
20{
26
39
41{
42 friend class Singleton<PacketLogServer, Mutex>;
43
44private:
47
48public:
49 void Initialize(std::string const& controlFileDefault, std::string const& outputDirDefault);
50 void Configure(std::string const& controlFile, std::string const& outputDir, std::string logsDir = "");
51 void ConfigureLegacyPacketLogFile(std::string const& packetLogFile);
52
53 bool CanLogPacket() const;
55 void DisableAllLogging();
56 void EnableCharacterLogging(std::string const& characterName);
57 void DisableCharacterLogging(std::string const& characterName);
58 bool IsGlobalLoggingEnabled() const;
59 size_t GetCharacterLoggingCount() const;
60
61 void LogPacket(void const* sessionKey, PacketLogServerSessionInfo const& sessionInfo,
62 PacketLogServerDirection direction, uint32 opcode, std::string const& opcodeName,
63 void const* payload, size_t payloadSize);
64 void LogBinaryPacket(PacketLogServerDirection direction, uint32 opcode, void const* payload, size_t payloadSize);
65 void LogMarker(void const* sessionKey, PacketLogServerSessionInfo const& sessionInfo, std::string const& marker);
66 void RefreshSessionInfo(void const* sessionKey, PacketLogServerSessionInfo const& sessionInfo);
67 void CloseSession(void const* sessionKey);
68
69private:
77
78 bool IsControlFileLoggingEnabled() const;
79 bool ShouldLogSession(PacketLogServerSessionInfo const& sessionInfo) const;
80 FILE* OpenSessionLog(void const* sessionKey, PacketLogServerSessionInfo const& sessionInfo);
81 void CloseAllSessions();
82 void CloseCharacterSessions(std::string const& normalizedName);
83
84 std::string _logsDir;
86 std::vector<std::string> _controlFiles;
87 std::string _sessionLogDir;
89 std::unordered_set<std::string> _characterSessionLogging;
90 mutable std::mutex _sessionLock;
91 std::unordered_map<void const*, SessionLog> _sessionLogs;
92};
93}
94
95#define sPacketLogServer Skyfire::Singleton<Skyfire::PacketLogServer, Skyfire::Mutex>::instance()
96
97#endif
std::uint32_t uint32
Definition Define.h:77
std::uint64_t uint64
Definition Define.h:76
void EnableCharacterLogging(std::string const &characterName)
void Initialize(std::string const &controlFileDefault, std::string const &outputDirDefault)
std::vector< std::string > _controlFiles
void LogBinaryPacket(PacketLogServerDirection direction, uint32 opcode, void const *payload, size_t payloadSize)
void DisableCharacterLogging(std::string const &characterName)
std::unordered_set< std::string > _characterSessionLogging
bool IsControlFileLoggingEnabled() const
void CloseSession(void const *sessionKey)
void LogPacket(void const *sessionKey, PacketLogServerSessionInfo const &sessionInfo, PacketLogServerDirection direction, uint32 opcode, std::string const &opcodeName, void const *payload, size_t payloadSize)
void Configure(std::string const &controlFile, std::string const &outputDir, std::string logsDir="")
void RefreshSessionInfo(void const *sessionKey, PacketLogServerSessionInfo const &sessionInfo)
size_t GetCharacterLoggingCount() const
void CloseCharacterSessions(std::string const &normalizedName)
std::unordered_map< void const *, SessionLog > _sessionLogs
void LogMarker(void const *sessionKey, PacketLogServerSessionInfo const &sessionInfo, std::string const &marker)
void ConfigureLegacyPacketLogFile(std::string const &packetLogFile)
FILE * OpenSessionLog(void const *sessionKey, PacketLogServerSessionInfo const &sessionInfo)
bool ShouldLogSession(PacketLogServerSessionInfo const &sessionInfo) const
@ PACKET_LOG_SERVER_TO_CLIENT
@ PACKET_LOG_CLIENT_TO_SERVER
PacketLogServerSessionInfo info