UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DiagnosticTable.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 DiagnosticTable.h: Diagnostic table implementation
5=============================================================================*/
6
7#pragma once
8
9#include "CoreTypes.h"
10#include "Misc/VarArgs.h"
14#include "Misc/DateTime.h"
15#include "HAL/PlatformProcess.h"
16#include "HAL/FileManager.h"
17#include "Misc/Paths.h"
18
19#if ALLOW_DEBUG_FILES
20
25{
26public:
27
30 : OutputStream(InOutputStream)
31 {}
32
35 {
36 // Ensure the user flushed the last row to the output.
37 check(!CurrentRow.Len());
38
39 // Close the output stream.
40 Close();
41 }
42
44 void AddColumn(const TCHAR* Format,...)
45 {
46 check(OutputStream);
47
48 // Format the input string.
49 TCHAR ColumnText[4096];
51
52 // If this isn't the first column in the row, add a comma to separate the columns.
53 if(CurrentRow.Len())
54 {
55 CurrentRow += TEXT(',');
56 }
57
58 // Replace quotes in the column with doubles quotes.
59 FString EscapedText = ColumnText;
60 EscapedText = EscapedText.Replace(TEXT("\""),TEXT("\"\""));
61
62 // Append the enquoted column to the current row.
63 CurrentRow += TEXT('\"');
65 CurrentRow += TEXT('\"');
66 }
67
69 void CycleRow()
70 {
71 check(OutputStream);
72
73 // Write the current row to the output stream.
74 OutputStream->Logf(TEXT("%s"),*CurrentRow);
75
76 // Reset the current row.
77 CurrentRow.Empty();
78 }
79
81 void Close()
82 {
83 if(OutputStream)
84 {
85 // Close the output stream.
86 OutputStream->Close();
87 OutputStream = NULL;
88 }
89 }
90
93 {
94 return (OutputStream != NULL);
95 }
96
97private:
98
100 FString CurrentRow;
101
103 FArchive* OutputStream;
104};
105
108{
109public:
110
112 static FString GetUniqueTemporaryFilePath(const TCHAR* BaseName)
113 {
114 return FString::Printf(TEXT("%sLogs/%s-%s.csv"), *FPaths::ProjectDir(), BaseName, *FDateTime::Now().ToString());
115 }
116
123 {}
124
127 {
128 OpenViewer();
129 }
130
132 void OpenViewer()
133 {
134 if(FPlatformProperties::HasEditorOnlyData() && !bHasOpenedViewer && !bSuppressViewer)
135 {
136 bHasOpenedViewer = true;
137
138 // Close the writer.
139 Close();
140
141 // Open the viewer.
142 FPlatformProcess::LaunchURL(*FString::Printf(TEXT("%s"),*IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*TemporaryFilePath)), NULL, NULL);
143 }
144 }
145
146private:
147
149 bool bHasOpenedViewer;
150
151 bool bSuppressViewer;
152
154 FString TemporaryFilePath;
155};
156
157#endif
158
#define NULL
Definition oodle2base.h:134
#define check(expr)
Definition AssertionMacros.h:314
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
JsonWriter Close()
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
#define GET_TYPED_VARARGS(CharType, msg, msgsize, len, lastarg, fmt)
Definition VarArgs.h:17
Definition Archive.h:1208
static CORE_API FString ProjectDir()
Definition Paths.cpp:457
Definition FileManager.h:57
static CORE_API IFileManager & Get()
Definition FileManagerGeneric.cpp:1072
FString ToString(uint16 Value)
Definition PathFollowingComponent.cpp:82
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
@ false
Definition radaudio_common.h:23
static CORE_API void LaunchURL(const TCHAR *URL, const TCHAR *Parms, FString *Error)
Definition AndroidPlatformProcess.cpp:132
static CORE_API FDateTime Now()
Definition DateTime.cpp:377