Skip to content

Commit 178ba53

Browse files
committed
Add DISABLE_BETAHUB_LOGGER
1 parent dff1c2f commit 178ba53

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

Documentation.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,29 @@ <h2>IL2CPP Support and FFmpeg Video Recording</h2>
114114
</ul>
115115
</div>
116116

117+
<div class="warning">
118+
<h2>Performance: Disabling Logger</h2>
119+
<p><strong>If you need to disable BetaHub's logging system for performance reasons or production builds:</strong></p>
120+
<ul>
121+
<li>Define the scripting symbol <code>DISABLE_BETAHUB_LOGGER</code> in Player Settings > Scripting Define Symbols</li>
122+
<li>This prevents the logger from capturing Unity logs, which can cause:
123+
<ul>
124+
<li>File I/O operations every time Unity logs a message</li>
125+
<li>CPU overhead from continuous disk writes</li>
126+
<li>File access violations when multiple Unity instances run simultaneously</li>
127+
</ul>
128+
</li>
129+
<li>Bug reports will still work, but won't include captured Unity logs</li>
130+
<li>A warning will be displayed when BugReportUI starts with logging disabled</li>
131+
</ul>
132+
<p><strong>When to use:</strong></p>
133+
<ul>
134+
<li>Production builds where logging overhead impacts performance</li>
135+
<li>Multi-instance Unity scenarios (automated testing, CI/CD)</li>
136+
<li>Projects with high-frequency logging that causes file access issues</li>
137+
</ul>
138+
</div>
139+
117140
<h3>Quick Start</h3>
118141

119142
<div class="note">

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,20 @@ Join our [Discord server](https://discord.gg/g2wpRtG) for support, feedback, and
6363
- For IL2CPP: define `ENABLE_BETAHUB_FFMPEG` and ensure the native library is present.
6464
- For Mono/.NET: no special action is needed.
6565

66+
## ⚠️ Performance: Disabling Logger
67+
68+
**If you need to disable BetaHub's logging system for performance reasons or production builds:**
69+
70+
- Define the scripting symbol `DISABLE_BETAHUB_LOGGER` in Player Settings > Scripting Define Symbols
71+
- This prevents the logger from capturing Unity logs, which can cause:
72+
- File I/O operations every time Unity logs a message
73+
- CPU overhead from continuous disk writes
74+
- File access violations when multiple Unity instances run simultaneously
75+
- Bug reports will still work, but won't include captured Unity logs
76+
- A warning will be displayed when BugReportUI starts with logging disabled
77+
78+
**When to use:**
79+
- Production builds where logging overhead impacts performance
80+
- Multi-instance Unity scenarios (automated testing, CI/CD)
81+
- Projects with high-frequency logging that causes file access issues
82+

Runtime/Scripts/BugReportUI.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,13 @@ public class BugReportUI : MonoBehaviour
122122

123123
private bool _uiWasVisible = false;
124124

125+
#if !DISABLE_BETAHUB_LOGGER
125126
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
126127
private static void InitializeLogger()
127128
{
128129
_logger = new Logger();
129130
}
131+
#endif
130132

131133
void Awake()
132134
{
@@ -178,6 +180,10 @@ void Start()
178180
Debug.LogError("Project ID is not set. I won't be able to submit bug reports.");
179181
}
180182

183+
#if DISABLE_BETAHUB_LOGGER
184+
Debug.LogWarning("DISABLE_BETAHUB_LOGGER is enabled. Player logs will not be captured for bug reports. Remove this scripting define symbol to enable logging.");
185+
#endif
186+
181187
// Check for auth token if not using device auth
182188
if (string.IsNullOrEmpty(AuthToken))
183189
{
@@ -361,7 +367,7 @@ void SubmitBugReport()
361367
logFiles = new List<Issue.LogFileReference>(_logFiles);
362368

363369
// Add logger log file if it exists
364-
if (IncludePlayerLog && !string.IsNullOrEmpty(_logger.LogPath) && File.Exists(_logger.LogPath))
370+
if (IncludePlayerLog && _logger != null && !string.IsNullOrEmpty(_logger.LogPath) && File.Exists(_logger.LogPath))
365371
{
366372
// skip if size over 200MB
367373
if (new FileInfo(_logger.LogPath).Length < 200 * 1024 * 1024)

0 commit comments

Comments
 (0)