Skip to content

Commit 0168972

Browse files
committed
Logger: Fixed disposing of the logger error.
1 parent 981ec71 commit 0168972

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.4.1
4+
5+
### Fixed
6+
- Logger: Fixed disposing of the logger error.
7+
38
## 1.4.0
49

510
### Added

Runtime/Scripts/Logger.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public class Logger : IDisposable
1313
private StreamWriter writer;
1414
private List<string> logBuffer;
1515
private readonly object lockObject = new object();
16-
private float lastFlushTime;
16+
private DateTime lastFlushTime;
1717
private bool disposed = false;
1818

1919
private const int BUFFER_SIZE = 50;
20-
private const float FLUSH_INTERVAL = 2f;
20+
private static readonly TimeSpan FLUSH_INTERVAL = TimeSpan.FromSeconds(2);
2121

2222
public string LogPath => _logPath;
2323

@@ -33,7 +33,7 @@ public Logger()
3333
_logPath = Path.Combine(Application.persistentDataPath, logFileName);
3434

3535
logBuffer = new List<string>(BUFFER_SIZE);
36-
lastFlushTime = Time.realtimeSinceStartup;
36+
lastFlushTime = DateTime.UtcNow;
3737

3838
InitializeFileStream();
3939
}
@@ -75,7 +75,7 @@ private void WriteToLog(string log)
7575
logBuffer.Add(log);
7676

7777
bool shouldFlush = logBuffer.Count >= BUFFER_SIZE ||
78-
(Time.realtimeSinceStartup - lastFlushTime) >= FLUSH_INTERVAL;
78+
(DateTime.UtcNow - lastFlushTime) >= FLUSH_INTERVAL;
7979

8080
if (shouldFlush)
8181
{
@@ -105,7 +105,7 @@ private void FlushBuffer()
105105
writer.Flush();
106106
fileStream.Flush();
107107
logBuffer.Clear();
108-
lastFlushTime = Time.realtimeSinceStartup;
108+
lastFlushTime = DateTime.UtcNow;
109109
}
110110
catch (ObjectDisposedException)
111111
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.betahub.bugreporter",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"displayName": "BetaHub Bug Reporter",
55
"description": "A tool for recording gameplay videos and submitting bug reports directly to BetaHub.",
66
"unity": "2022.3",

0 commit comments

Comments
 (0)