@@ -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 {
0 commit comments