UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Channel.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Trace/Config.h"
6#include "Trace/Trace.h"
7
8#if TRACE_PRIVATE_MINIMAL_ENABLED
9
10#include "CoreTypes.h"
11
12namespace UE {
13namespace Trace {
14
15
16typedef bool ChannelIterCallback(const FChannelInfo& OutChannelInfo, void*);
17
18/*
19 A named channel which can be used to filter trace events. Channels can be
20 combined using the '|' operator which allows expressions like
21
22 ```
23 UE_TRACE_LOG(FooWriter, FooEvent, FooChannel|BarChannel);
24 ```
25
26 Note that this works as an AND operator, similar to how a bitmask is constructed.
27
28 Channels are by default enabled until FChannel::Initialize() is called. This is to allow
29 events to be emitted during static initialization. In fact all events during
30 this phase are always emitted.
31*/
32class FChannel
33{
34public:
35 struct Iter
36 {
37 ~Iter();
38 const FChannel* GetNext();
39 void*Inner[3];
40 };
41
42 struct InitArgs
43 {
47 const ANSICHAR* Desc;
51 bool bReadOnly;
52 };
53
57 TRACELOG_API void Setup(const ANSICHAR* InChannelName, const InitArgs& Args);
58
66 virtual bool OnToggle(bool bNewState, const TCHAR** OutReason) { return true; }
67
74 virtual void OnToggled(bool bNewState) {}
75
84 TRACELOG_API bool Toggle(bool bEnabled, const TCHAR** OutReason = nullptr);
85
86 static void Initialize();
87 static Iter ReadNew();
88 void Announce() const;
89 static bool Toggle(const ANSICHAR* ChannelName, bool bEnabled);
90 static void ToggleAll(bool bEnabled);
91 static void PanicDisableAll(); // Disabled channels wont be logged with UE_TRACE_LOG
92 static FChannel* FindChannel(const ANSICHAR* ChannelName);
93 static FChannel* FindChannel(FChannelId ChannelId);
94 static void EnumerateChannels(ChannelIterCallback Func, void* User);
95 bool IsEnabled() const;
96 bool IsReadOnly() const { return Args.bReadOnly; };
97 uint32 GetName(const ANSICHAR** OutName) const;
98 explicit operator bool () const;
99 bool operator | (const FChannel& Rhs) const;
100
101private:
102 bool ToggleInternal(bool bEnabled, bool bIssueCallback, const TCHAR** OutReason = nullptr);
103 static void ToggleAllInternal(bool bEnabled, bool bIssueCallback);
104
105 FChannel* Next;
106 struct
107 {
108 const ANSICHAR* Ptr;
109 uint32 Len;
110 uint32 Hash;
111 } Name;
112 volatile int32 Enabled;
113 InitArgs Args;
114 volatile uint8 Lock;
115};
116
117inline uint32 FChannel::GetName(const ANSICHAR** OutName) const
118{
119 if (OutName != nullptr)
120 {
121 *OutName = Name.Ptr;
122 return Name.Len;
123 }
124 return 0;
125}
126
127
128} // namespace Trace
129} // namespace UE
130
131#else
132
133// Since we use this type in macros we need
134// provide an empty definition when trace is
135// not enabled.
136namespace UE::Trace { class FChannel {}; }
137
138#endif // TRACE_PRIVATE_MINIMAL_ENABLED
constexpr EUpdateTransformFlags operator|(EUpdateTransformFlags Left, EUpdateTransformFlags Right)
Definition ActorComponent.h:106
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
FRWLock Lock
Definition UnversionedPropertySerialization.cpp:921
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Channel.h:136
bool IsEnabled()
Definition IAudioLinkFactory.cpp:13
@ Trace
Definition NetTraceConfig.h:23
IMAGECORE_API const TCHAR * GetName(Type Format)
Definition ImageCore.cpp:1378
const TCHAR * Name
Definition OodleDataCompression.cpp:30
uint32 GetNext(uint32 Index, const IndexType *NextIndexData, const uint32 NextIndexCount)
Definition CompactHashTable.h:116
Definition ModuleDiagnostics.h:7
uint32 FChannelId
Definition Trace.h:155
bool ChannelIterCallback(const FChannelInfo &Info, void *)
Definition Trace.h:197
UE_TRACE_API void EnumerateChannels(ChannelIterFunc IterFunc, void *User) UE_TRACE_IMPL()
UE_TRACE_API FChannel * FindChannel(const TCHAR *ChannelName) UE_TRACE_IMPL(nullptr)
Definition AdvancedWidgetsModule.cpp:13