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
23#include <boost/asio/ip/address.hpp>
24#include <mutex>
25
31
32class WorldPacket;
33
35{
36 private:
37 PacketLog();
38 ~PacketLog();
39 std::mutex _logPacketLock;
40 std::once_flag _initializeFlag;
41
42 public:
43 static PacketLog* instance();
44
45 void Initialize();
46 bool CanLogPacket() const { return (_file != nullptr); }
47 void LogPacket(WorldPacket const& packet, Direction direction, boost::asio::ip::address const& addr, uint16 port);
48
49 private:
50 FILE* _file;
51};
52
53#define sPacketLog PacketLog::instance()
54#endif
#define TC_GAME_API
Definition Define.h:114
uint16_t uint16
Definition Define.h:134
Direction
Definition PacketLog.h:27
@ SERVER_TO_CLIENT
Definition PacketLog.h:29
@ CLIENT_TO_SERVER
Definition PacketLog.h:28
FILE * _file
Definition PacketLog.h:50
bool CanLogPacket() const
Definition PacketLog.h:46
std::once_flag _initializeFlag
Definition PacketLog.h:40
std::mutex _logPacketLock
Definition PacketLog.h:39