Attribute VB_Name = "PacketLogger"
Option Explicit

Public Function PacketLog(Packet As String, ServerToClientPacket As Boolean, EncryptedPacket As Boolean)

If FrmBrowser.PacketLogger = False Then Exit Function

'Packet Logger
'If FrmBrowser.PublicKeySet = False Then
  If ServerToClientPacket = True Then
    If Len(FrmPackets.txt_packetlogs_enc.Text) > 12000 And FrmPackets.chk_pause_enc.value = 0 Then
    FrmPackets.txt_packetlogs_enc.Text = ""
    End If
    If FrmPackets.chk_pause_enc.value = 0 Then
    FrmPackets.txt_packetlogs_enc.Text = FrmPackets.txt_packetlogs_enc.Text & "[" & Format(Now, "hh:mm:ss") & "] - Server to Client [Uncrypted]:" & vbNewLine & Packet & vbNewLine & "----------------------------------------------------------" & vbNewLine
    txt_AppendLine App.path & "\PacketLog.txt", "[" & Format(Now, "hh:mm:ss") & "] - Server to Client [Uncrypted]:" & vbNewLine & Packet & vbNewLine & "----------------------------------------------------------"
    End If
  ElseIf ServerToClientPacket = False Then
    If Len(FrmPackets.txt_packetlogs_dec.Text) > 12000 And FrmPackets.chk_pause_dec.value = 0 Then
    FrmPackets.txt_packetlogs_dec.Text = ""
    End If
      If EncryptedPacket = True Then
        If FrmPackets.chk_pause_dec.value = 0 Then
        FrmPackets.txt_packetlogs_dec.Text = FrmPackets.txt_packetlogs_dec.Text & "[" & Format(Now, "hh:mm:ss") & "] - Client to Server [Encrypted]:" & vbNewLine & Packet & vbNewLine & "----------------------------------------------------------" & vbNewLine
        txt_AppendLine App.path & "\PacketLog.txt", "[" & Format(Now, "hh:mm:ss") & "] - Client to Server [Encrypted]:" & vbNewLine & Packet & vbNewLine & "----------------------------------------------------------"
        End If
      ElseIf EncryptedPacket = False Then
        If FrmPackets.chk_pause_dec.value = 0 Then
        FrmPackets.txt_packetlogs_dec.Text = FrmPackets.txt_packetlogs_dec.Text & "[" & Format(Now, "hh:mm:ss") & "] - Client to Server [Decrypted]:" & vbNewLine & Packet & vbNewLine & "----------------------------------------------------------" & vbNewLine
        txt_AppendLine App.path & "\PacketLog.txt", "[" & Format(Now, "hh:mm:ss") & "] - Client to Server [Decrypted]:" & vbNewLine & Packet & vbNewLine & "----------------------------------------------------------"
        End If
      End If
  End If

End Function

