[Test] public void TraceWithReasonAndInner2() { var t0 = new T("SetPos", next: null, reason: "Teleport"); var t1 = new T("Reposition", next: t0, reason: null); o(F.LogTrace(t0), "SetPos (Teleport)"); o(F.LogTrace(t1), "Reposition -> SetPos (Teleport)"); }
[Test] public void Prefix() { var t = new T("SetPos", next: null, reason: null); t.Prefix('!'); o(F.LogTrace(t), "!SetPos"); t.Prefix('+'); o(F.LogTrace(t), "+!SetPos"); }
internal Meta(LogTrace t, status[] c = null, status.Ref prev = null) { if (t == null) { throw new System.Exception(); } trace = t; components = c; this.prev = prev; }
public LogTrace(object scope, LogTrace next, string reason) { if (!status.log) { throw new InvEx("Logging is disabled"); } this.scope = scope.ToString(); this.isDecorator = scope is IDecorator; this.next = next; this.reason = TraceFormat.ReasonField(reason); }
// StatusFormat uses this to format the trace attached to a status. public static string LogTrace(LogTrace trace) { if (trace == null) { return("?trace"); } var @out = string.Format( "{0}{1} {2}", trace.prefix ?? null, trace.scope, Reason(trace.reason, trace.isDecorator) ).Trim(); return(trace.next == null ? @out : $"{@out} -> {LogTrace(trace.next)}"); }
[Test] public void TraceDecoratorWithReason() { var t = new T(new Cooldown(), next: null, reason: "[5] Steer"); o(F.LogTrace(t), "<C> [5] Steer"); }
[Test] public void TraceWithReasonAndFormatArgs() { var t = new T("SetPos", next: null, reason: "Teleport here"); o(F.LogTrace(t), "SetPos (Teleport here)"); }
[Test] public void TraceWithReason() { var t = new T("SetPos", next: null, reason: "Teleport"); o(F.LogTrace(t), "SetPos (Teleport)"); }
[Test] public void LogTrace() { var t = new T("SetPos", next: null, reason: null); o(F.LogTrace(t), "SetPos"); }
public static string Scope(LogTrace t) => t?.scope.ToString();