# PacketLogger Class Reference
[PacketLogger]

Writes incoming and outgoing messages to the screen. This will write all incoming and outgoing messages to the console window, or to a file if you override it and give it this functionality. More...

`#include <PacketLogger.h>`

Inheritance diagram for PacketLogger:

List of all members.

## Public Member Functions
virtual void | OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
| Events on low level sends and receives. These functions may be called from different threads at the same time.
virtual void | OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnReliabilityLayerPacketError (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, RakNetTime time, int isSend)
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNetTime time)
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | LogHeader (void)
| Logs out a header for all the data.
virtual void | WriteLog (const char *str)
| Override this to log strings to wherever. Log should be threadsafe.
virtual void | SetPrefix (const char *_prefix)
| Prepend this string to output logs.
virtual void | SetSuffix (const char *_suffix)
| Append this string to output logs. (newline is useful here).
void | SetLogDirectMessages (bool send)
| Log the direct sends and receives or not. Default true.

## Detailed Description

Writes incoming and outgoing messages to the screen. This will write all incoming and outgoing messages to the console window, or to a file if you override it and give it this functionality.

## Member Function Documentation

virtual void PacketLogger::OnAck | ( | unsigned int | messageNumber,
|  | SystemAddress | remoteSystemAddress,
|  | RakNetTime | time |
| ) |  |  | `[virtual]`

Called when we get an ack for a message we reliabily sent

Parameters:

  `[in]` | messageNumber | The numerical identifier for which message this is
  `[in]` | remoteSystemAddress | The player we sent or got this packet from
  `[in]` | time | The current time as returned by RakNet::GetTime()

Reimplemented from PluginInterface2.

virtual void PacketLogger::OnDirectSocketReceive | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress |
| ) |  |  | `[virtual]`

Called on a receive from the socket, per datagram, that does not go through the reliability layer

Parameters:

  `[in]` | data | The data being sent
  `[in]` | bitsUsed | How many bits long data is
  `[in]` | remoteSystemAddress | Which system this message is being sent to

Reimplemented from PluginInterface2.

virtual void PacketLogger::OnInternalPacket | ( | InternalPacket * | internalPacket,
|  | unsigned | frameNumber,
|  | SystemAddress | remoteSystemAddress,
|  | RakNetTime | time,
|  | int | isSend |
| ) |  |  | `[virtual]`

Called on a send or receive of a message within the reliability layer

Parameters:

  `[in]` | internalPacket | The user message, along with all send data.
  `[in]` | frameNumber | The number of frames sent or received so far for this player depending on isSend . Indicates the frame of this user message.
  `[in]` | remoteSystemAddress | The player we sent or got this packet from
  `[in]` | time | The current time as returned by RakNet::GetTime()
  `[in]` | isSend | Is this callback representing a send event or receive event?

Reimplemented from PluginInterface2.

virtual void PacketLogger::OnPushBackPacket | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress |
| ) |  |  | `[virtual]`

System called RakPeerInterface::PushBackPacket

Parameters:

  `[in]` | data | The data being sent
  `[in]` | bitsUsed | How many bits long data is
  `[in]` | remoteSystemAddress | The player we sent or got this packet from

Reimplemented from PluginInterface2.

virtual void PacketLogger::OnReliabilityLayerPacketError | ( | const char * | errorMessage,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress |
| ) |  |  | `[virtual]`

Called when the reliability layer rejects a send or receive

Parameters:

  `[in]` | bitsUsed | How many bits long data is
  `[in]` | remoteSystemAddress | Which system this message is being sent to

Reimplemented from PluginInterface2.

The documentation for this class was generated from the following file:

- d:/RakNet-3.x/Source/PacketLogger.h