TrinityCore
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
25{
28};
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 static PacketLog* instance();
54
55 void Initialize();
56 bool CanLogPacket() const { return (_file != nullptr); }
57 void LogPacket(WorldPacket const& packet, Direction direction, boost::asio::ip::address const& addr, uint16 port, ConnectionType connectionType);
58
59 private:
60 FILE* _file;
61};
62
63#define sPacketLog PacketLog::instance()
64#endif
#define TC_GAME_API
Definition: Define.h:123
int8_t int8
Definition: Define.h:140
uint16_t uint16
Definition: Define.h:143
Direction
Definition: PacketLog.h:25
@ SERVER_TO_CLIENT
Definition: PacketLog.h:27
@ CLIENT_TO_SERVER
Definition: PacketLog.h:26
FILE * _file
Definition: PacketLog.h:60
bool CanLogPacket() const
Definition: PacketLog.h:56
std::once_flag _initializeFlag
Definition: PacketLog.h:50
std::mutex _logPacketLock
Definition: PacketLog.h:49
ConnectionType
Definition: Opcodes.h:29