mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-11 20:11:18 +03:00
* Initial commit.
:)
This commit is contained in:
55
thirdparty/raknet/PacketFileLogger.cpp
vendored
Normal file
55
thirdparty/raknet/PacketFileLogger.cpp
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oculus VR, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "NativeFeatureIncludes.h"
|
||||
#if _RAKNET_SUPPORT_PacketLogger==1
|
||||
#include "PacketFileLogger.h"
|
||||
#include "GetTime.h"
|
||||
|
||||
using namespace RakNet;
|
||||
|
||||
PacketFileLogger::PacketFileLogger()
|
||||
{
|
||||
packetLogFile=0;
|
||||
}
|
||||
PacketFileLogger::~PacketFileLogger()
|
||||
{
|
||||
if (packetLogFile)
|
||||
{
|
||||
fflush(packetLogFile);
|
||||
fclose(packetLogFile);
|
||||
}
|
||||
}
|
||||
void PacketFileLogger::StartLog(const char *filenamePrefix)
|
||||
{
|
||||
// Open file for writing
|
||||
char filename[256];
|
||||
if (filenamePrefix)
|
||||
sprintf(filename, "%s_%i.csv", filenamePrefix, (int) RakNet::GetTimeMS());
|
||||
else
|
||||
sprintf(filename, "PacketLog_%i.csv", (int) RakNet::GetTimeMS());
|
||||
packetLogFile = fopen(filename, "wt");
|
||||
LogHeader();
|
||||
if (packetLogFile)
|
||||
{
|
||||
fflush(packetLogFile);
|
||||
}
|
||||
}
|
||||
|
||||
void PacketFileLogger::WriteLog(const char *str)
|
||||
{
|
||||
if (packetLogFile)
|
||||
{
|
||||
fprintf(packetLogFile, "%s\n", str);
|
||||
fflush(packetLogFile);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _RAKNET_SUPPORT_*
|
||||
Reference in New Issue
Block a user