Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
OutputDeviceMemory.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "CoreTypes.h"
7#include "HAL/CriticalSection.h"
8#include "Logging/LogVerbosity.h"
9#include "Misc/OutputDevice.h"
10#include "Serialization/Archive.h"
11#include "UObject/NameTypes.h"
12
13/**
14 * Memory output device. Logs only into pre-allocated memory buffer.
15 */
17{
19 {
21 public:
23 : OutputDevice(InOutputDevice)
24 {}
25 virtual void Serialize(void* V, int64 Length) override
26 {
27 OutputDevice.SerializeToBuffer((ANSICHAR*)V, Length / sizeof(ANSICHAR));
28 }
29 } ArchiveProxy;
30
31public:
32 /**
33 * Constructor, initializing member variables.
34 *
35 * @param InPreserveSize Bytes of the rung buffer not to overwrite (startup info etc)
36 * @param InBufferSize Maximum size of the memory ring buffer
37 */
38 FOutputDeviceMemory(int32 InPreserveSize = 256 * 1024, int32 InBufferSize = 2048 * 1024, bool bInSuppressEventTag = false);
39
40 /** Dumps the contents of the buffer to an archive */
41 virtual void Dump(FArchive& Ar) override;
42
43 //~ Begin FOutputDevice Interface.
44 /**
45 * Closes output device and cleans up. This can't happen in the destructor
46 * as we have to call "delete" which cannot be done for static/ global
47 * objects.
48 */
49 virtual void TearDown() override;
50
51 /**
52 * Flush the write cache so the file isn't truncated in case we crash right
53 * after calling this function.
54 */
55 virtual void Flush() override;
56
57 virtual void Serialize( const TCHAR* Data, ELogVerbosity::Type Verbosity, const class FName& Category, const double Time ) override;
58 virtual void Serialize( const TCHAR* Data, ELogVerbosity::Type Verbosity, const class FName& Category) override;
59 virtual bool CanBeUsedOnAnyThread() const override
60 {
61 return true;
62 }
63 virtual bool CanBeUsedOnPanicThread() const override
64 {
65 return true;
66 }
67 virtual bool IsMemoryOnly() const override
68 {
69 return true;
70 }
71 //~ End FOutputDevice Interface.
72
73private:
74
75 /** Serialize cast data to the actual memory buffer */
76 void SerializeToBuffer(ANSICHAR* Data, int32 Length);
77
78 /** Ring buffer */
80 /** Position where data starts in the buffer */
82 /** Used data size */
84 /** Amount of data not to overwrite */
86 /** Sync object for the buffer pos */
88};
FWindowsCriticalSection FCriticalSection
FOutputDeviceMemoryProxyArchive(FOutputDeviceMemory &InOutputDevice)
virtual void Serialize(void *V, int64 Length) override
virtual void Flush() override
virtual bool CanBeUsedOnAnyThread() const override
FCriticalSection BufferPosCritical
virtual void Dump(FArchive &Ar) override
virtual bool IsMemoryOnly() const override
virtual bool CanBeUsedOnPanicThread() const override
virtual void Serialize(const TCHAR *Data, ELogVerbosity::Type Verbosity, const class FName &Category) override
TArray< ANSICHAR > Buffer
void SerializeToBuffer(ANSICHAR *Data, int32 Length)
virtual void Serialize(const TCHAR *Data, ELogVerbosity::Type Verbosity, const class FName &Category, const double Time) override
virtual void TearDown() override
FOutputDeviceMemory(int32 InPreserveSize=256 *1024, int32 InBufferSize=2048 *1024, bool bInSuppressEventTag=false)