TrinityCore
Loading...
Searching...
No Matches
PacketLog.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_PACKETLOG_H
19#define TRINITY_PACKETLOG_H
20
21#include "Common.h"
22#include <mutex>
23
29
30class WorldPacket;
31enum ConnectionType : int8;
32
33namespace boost
34{
35 namespace asio
36 {
37 namespace ip
38 {
39 class address;
40 }
41 }
42}
43
45{
46 private:
47 PacketLog();
48 ~PacketLog();
49 std::mutex _logPacketLock;
50 std::once_flag _initializeFlag;
51
52 public:
53 PacketLog(PacketLog const&) = delete;
54 PacketLog(PacketLog&&) = delete;
55 PacketLog& operator=(PacketLog const&) = delete;
57
58 static PacketLog* instance();
59
60 void Initialize();
61 bool CanLogPacket() const { return (_file != nullptr); }
62 void LogPacket(WorldPacket const& packet, Direction direction, boost::asio::ip::address const& addr, uint16 port, ConnectionType connectionType);
63
64 private:
65 FILE* _file;
66};
67
68#define sPacketLog PacketLog::instance()
69#endif
#define TC_GAME_API
Definition Define.h:129
int8_t int8
Definition Define.h:152
uint16_t uint16
Definition Define.h:155
ConnectionType
Definition Opcodes.h:27
Direction
Definition PacketLog.h:25
@ SERVER_TO_CLIENT
Definition PacketLog.h:27
@ CLIENT_TO_SERVER
Definition PacketLog.h:26
FILE * _file
Definition PacketLog.h:65
PacketLog & operator=(PacketLog &&)=delete
bool CanLogPacket() const
Definition PacketLog.h:61
std::once_flag _initializeFlag
Definition PacketLog.h:50
PacketLog(PacketLog const &)=delete
PacketLog(PacketLog &&)=delete
PacketLog & operator=(PacketLog const &)=delete
std::mutex _logPacketLock
Definition PacketLog.h:49