60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
|
|
namespace BrewMonster
|
|
{
|
|
/// <summary>NDJSON debug session logger (agent instrumentation).</summary>
|
|
public static class DebugSessionLog
|
|
{
|
|
const string LogPath = @"c:\Hoang\PW\debug-a9c674.log";
|
|
const string SessionId = "a9c674";
|
|
|
|
public static void Write(string location, string message, string hypothesisId, object data, string runId = "pre-fix")
|
|
{
|
|
try
|
|
{
|
|
var ts = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
var dataJson = data != null ? JsonUtility.ToJson(data) : "{}";
|
|
var line = $"{{\"sessionId\":\"{SessionId}\",\"runId\":\"{runId}\",\"hypothesisId\":\"{hypothesisId}\",\"location\":\"{Escape(location)}\",\"message\":\"{Escape(message)}\",\"data\":{dataJson},\"timestamp\":{ts}}}\n";
|
|
File.AppendAllText(LogPath, line, Encoding.UTF8);
|
|
}
|
|
catch { /* ignore */ }
|
|
}
|
|
|
|
static string Escape(string s) => (s ?? "").Replace("\\", "\\\\").Replace("\"", "\\\"");
|
|
}
|
|
|
|
[Serializable]
|
|
public class DebugSessionPayload
|
|
{
|
|
public int skillId;
|
|
public int hostId;
|
|
public int castTargetId;
|
|
public int targetId;
|
|
public int targetCount;
|
|
public bool castInTargets;
|
|
public bool alreadyFired;
|
|
public int flyClusterCount;
|
|
public int flyDelayMs;
|
|
public int eventId;
|
|
public string flyGfx;
|
|
public string prevState;
|
|
public string newState;
|
|
public int frame;
|
|
public float spawnX;
|
|
public float spawnY;
|
|
public float spawnZ;
|
|
public float targetX;
|
|
public float targetY;
|
|
public float targetZ;
|
|
public float radius;
|
|
public float offsetMag;
|
|
public bool isCluster;
|
|
public bool isArea;
|
|
}
|
|
}
|
|
#endif
|