some syntax and such and adde an editor tool for visualising logs

This commit is contained in:
Sebastian Bularca
2026-04-05 14:49:53 +02:00
parent 31951cfbf8
commit 947c8feb53
7 changed files with 1360 additions and 17 deletions

View File

@@ -4,10 +4,10 @@ using UnityEngine;
namespace Jovian.InGameLogging {
public sealed class GameLogStore : IGameLogStore {
readonly LogEntry[] buffer;
readonly HashSet<LogChannel> disabledChannels = new();
int head;
int count;
private readonly LogEntry[] buffer;
private readonly HashSet<LogChannel> disabledChannels = new();
private int head;
private int count;
public int Count => count;
public int Capacity => buffer.Length;
@@ -55,7 +55,7 @@ namespace Jovian.InGameLogging {
public void Clear(LogChannel channel) {
var kept = new List<LogEntry>(count);
var entries = GetEntries();
for(int i = 0; i < entries.Length; i++) {
for(var i = 0; i < entries.Length; i++) {
if(entries[i].channel != channel) {
kept.Add(entries[i]);
}
@@ -76,8 +76,8 @@ namespace Jovian.InGameLogging {
return new ReadOnlySpan<LogEntry>(buffer, 0, count);
}
var result = new LogEntry[count];
int start = head;
for(int i = 0; i < count; i++) {
var start = head;
for(var i = 0; i < count; i++) {
result[i] = buffer[(start + i) % buffer.Length];
}
return result;
@@ -86,7 +86,7 @@ namespace Jovian.InGameLogging {
public int GetEntries(LogChannel channel, List<LogEntry> results) {
results.Clear();
var entries = GetEntries();
for(int i = 0; i < entries.Length; i++) {
for(var i = 0; i < entries.Length; i++) {
if(entries[i].channel == channel) {
results.Add(entries[i]);
}
@@ -97,8 +97,8 @@ namespace Jovian.InGameLogging {
public GameLogSaveData GetSaveData() {
var entries = GetEntries();
var list = new List<LogEntry>(entries.Length);
for(int i = 0; i < entries.Length; i++) {
list.Add(entries[i]);
foreach(var t in entries) {
list.Add(t);
}
return new GameLogSaveData(list);
}
@@ -110,8 +110,8 @@ namespace Jovian.InGameLogging {
OnCleared?.Invoke();
return;
}
int startIndex = Math.Max(0, data.entries.Count - buffer.Length);
for(int i = startIndex; i < data.entries.Count; i++) {
var startIndex = Math.Max(0, data.entries.Count - buffer.Length);
for(var i = startIndex; i < data.entries.Count; i++) {
buffer[count] = data.entries[i];
count++;
}

View File

@@ -2,8 +2,8 @@ using System.Runtime.CompilerServices;
namespace Jovian.InGameLogging {
public readonly struct InGameLogger {
readonly IGameLogStore store;
readonly LogChannel channel;
private readonly IGameLogStore store;
private readonly LogChannel channel;
public InGameLogger(IGameLogStore store, LogChannel channel) {
this.store = store;