mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 14:56:06 +02:00
Log watcher init after browser
This commit is contained in:
+25
-17
@@ -33,8 +33,9 @@ namespace VRCX
|
||||
private ReaderWriterLockSlim m_LogListLock;
|
||||
private bool m_FirstRun = true;
|
||||
private bool m_ResetLog;
|
||||
private Thread m_Thread;
|
||||
private DateTime tillDate = DateTime.UtcNow;
|
||||
private bool threadActive;
|
||||
private Thread? m_Thread;
|
||||
private DateTime tillDate;
|
||||
public bool VrcClosedGracefully;
|
||||
private readonly ConcurrentQueue<string> m_LogQueue = new ConcurrentQueue<string>(); // for electron
|
||||
|
||||
@@ -62,6 +63,7 @@ namespace VRCX
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
threadActive = false;
|
||||
var thread = m_Thread;
|
||||
m_Thread = null;
|
||||
thread.Interrupt();
|
||||
@@ -77,6 +79,7 @@ namespace VRCX
|
||||
public void SetDateTill(string date)
|
||||
{
|
||||
tillDate = DateTime.Parse(date, CultureInfo.InvariantCulture, DateTimeStyles.None).ToUniversalTime();
|
||||
threadActive = true;
|
||||
logger.Info("SetDateTill: {0}", tillDate.ToLocalTime());
|
||||
}
|
||||
|
||||
@@ -84,7 +87,8 @@ namespace VRCX
|
||||
{
|
||||
while (m_Thread != null)
|
||||
{
|
||||
Update();
|
||||
if (threadActive)
|
||||
Update();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -130,15 +134,11 @@ namespace VRCX
|
||||
foreach (var fileInfo in fileInfos)
|
||||
{
|
||||
fileInfo.Refresh();
|
||||
if (fileInfo.Exists == false)
|
||||
{
|
||||
if (!fileInfo.Exists)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (DateTime.Compare(fileInfo.LastWriteTimeUtc, tillDate) < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_LogContextMap.TryGetValue(fileInfo.Name, out var logContext))
|
||||
{
|
||||
@@ -151,9 +151,7 @@ namespace VRCX
|
||||
}
|
||||
|
||||
if (logContext.Length == fileInfo.Length)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
logContext.Length = fileInfo.Length;
|
||||
ParseLog(fileInfo, logContext);
|
||||
@@ -491,14 +489,19 @@ namespace VRCX
|
||||
return true;
|
||||
|
||||
var userInfo = ParseUserInfo(line.Substring(lineOffset));
|
||||
if (string.IsNullOrEmpty(userInfo.DisplayName) && string.IsNullOrEmpty(userInfo.UserId))
|
||||
{
|
||||
logger.Warn("Failed to parse user info from log line: {0}", line);
|
||||
return true;
|
||||
}
|
||||
|
||||
AppendLog(new[]
|
||||
{
|
||||
fileInfo.Name,
|
||||
ConvertLogTimeToISO8601(line),
|
||||
"player-joined",
|
||||
userInfo.DisplayName,
|
||||
userInfo.UserId
|
||||
userInfo.DisplayName ?? string.Empty,
|
||||
userInfo.UserId ?? string.Empty
|
||||
});
|
||||
|
||||
return true;
|
||||
@@ -514,14 +517,19 @@ namespace VRCX
|
||||
return true;
|
||||
|
||||
var userInfo = ParseUserInfo(line.Substring(lineOffset));
|
||||
if (string.IsNullOrEmpty(userInfo.DisplayName) && string.IsNullOrEmpty(userInfo.UserId))
|
||||
{
|
||||
logger.Warn("Failed to parse user info from log line: {0}", line);
|
||||
return true;
|
||||
}
|
||||
|
||||
AppendLog(new[]
|
||||
{
|
||||
fileInfo.Name,
|
||||
ConvertLogTimeToISO8601(line),
|
||||
"player-left",
|
||||
userInfo.DisplayName,
|
||||
userInfo.UserId
|
||||
userInfo.DisplayName ?? string.Empty,
|
||||
userInfo.UserId ?? string.Empty
|
||||
});
|
||||
|
||||
return true;
|
||||
@@ -1392,10 +1400,10 @@ namespace VRCX
|
||||
return new string[][] { };
|
||||
}
|
||||
|
||||
private static (string DisplayName, string UserId) ParseUserInfo(string userInfo)
|
||||
private static (string? DisplayName, string? UserId) ParseUserInfo(string userInfo)
|
||||
{
|
||||
string userDisplayName;
|
||||
string userId;
|
||||
string? userDisplayName;
|
||||
string? userId;
|
||||
|
||||
int pos = userInfo.LastIndexOf(" (", StringComparison.Ordinal);
|
||||
if (pos >= 0)
|
||||
|
||||
@@ -951,7 +951,6 @@ export default class extends baseClass {
|
||||
|
||||
async updateGameLog(dateTill) {
|
||||
await gameLogService.setDateTill(dateTill);
|
||||
await gameLogService.reset();
|
||||
await new Promise((resolve) => {
|
||||
workerTimers.setTimeout(resolve, 10000);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user