Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci-build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v5
Expand Down Expand Up @@ -73,6 +74,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v5
Expand Down Expand Up @@ -116,6 +118,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Setup .NET
uses: actions/setup-dotnet@v5
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci-linux-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6
Expand Down Expand Up @@ -60,6 +61,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6
Expand Down Expand Up @@ -89,6 +91,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6
Expand Down
51 changes: 5 additions & 46 deletions .github/workflows/ci-linux-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6
Expand Down Expand Up @@ -81,6 +82,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6
Expand All @@ -100,29 +102,6 @@ jobs:
bash ./tools/ci/clang_tidy.sh build
"

cargo-log-server:
name: Cargo log_server (${{ matrix.build_type }})
runs-on: [self-hosted, Linux, X64]
strategy:
matrix:
build_type: [debug, release]
fail-fast: false
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6

- name: Cargo build
env:
RELEASE_FLAG: ${{ matrix.build_type == 'release' && '--release' || '' }}
run: nix develop --command bash -c "rustup toolchain install stable --no-self-update && rustup default stable && cargo build --manifest-path tools/log_server/Cargo.toml $RELEASE_FLAG"

cargo-reflection-generator:
name: Cargo reflection_generator (${{ matrix.build_type }})
runs-on: [self-hosted, Linux, X64]
Expand All @@ -137,6 +116,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6
Expand All @@ -146,29 +126,6 @@ jobs:
RELEASE_FLAG: ${{ matrix.build_type == 'release' && '--release' || '' }}
run: nix develop --command bash -c "rustup toolchain install stable --no-self-update && rustup default stable && cargo build --manifest-path tools/reflection_generator/Cargo.toml $RELEASE_FLAG"

cargo-kenzo:
name: Cargo kenzo (${{ matrix.build_type }})
runs-on: [self-hosted, Linux, X64]
strategy:
matrix:
build_type: [debug, release]
fail-fast: false
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6

- name: Cargo build
env:
RELEASE_FLAG: ${{ matrix.build_type == 'release' && '--release' || '' }}
run: nix develop --command bash -c "rustup toolchain install stable --no-self-update && rustup default stable && cargo build --manifest-path tools/kenzo/Cargo.toml $RELEASE_FLAG"

dotnet-editor:
name: Dotnet editor (${{ matrix.build_type }})
runs-on: [self-hosted, Linux, X64]
Expand All @@ -183,6 +140,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6
Expand All @@ -204,6 +162,7 @@ jobs:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
fetch-depth: 1
submodules: true

- name: Install Nix
uses: cachix/install-nix-action@v31.10.6
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tools/kenzo"]
path = tools/kenzo
url = https://github.com/ynks/kenzo
4 changes: 2 additions & 2 deletions docs/logging_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
>

The logging system provides an easy way to write logs and visualize them after the program
execution has finished. It contains a C++ implementation for producing messages, a Rust
server for receiving, processing and storing messages, and a Rust TUI for easily reading
execution has finished. It contains a C++ implementation for producing messages, a C++
server for receiving, processing and storing messages, and a TUI for easily reading
and searching for information after reading.

To use this system you can simply just include `<Toast/Log.hpp>` and call any of the toast
Expand Down
11 changes: 11 additions & 0 deletions editor/Engine/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public static void Critical(
Dispatch(toast_critical, message, Path.GetFileName(fileName), (uint)lineNumber);
}

public static void InvalidateBacktraceCache() {
try {
toast_log_invalidate_backtraces();
} catch (DllNotFoundException) {
// Nothing was resolved without the engine
}
}

// Fallback to the console if toast-engine is not loaded
private static void Dispatch(
Action<string, string, string, uint> sink, string message, string fileName, uint lineNumber) {
Expand All @@ -56,4 +64,7 @@ private static void Dispatch(

[LibraryImport("toast_engine", StringMarshalling = StringMarshalling.Utf8)]
private static partial void toast_critical(string sink, string message, string fileName, uint lineNumber);

[LibraryImport("toast_engine")]
private static partial void toast_log_invalidate_backtraces();
}
8 changes: 7 additions & 1 deletion editor/Engine/ToastEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public void ReloadGame() {
Log.Info($"Reloading game library: {gameDll}");
File.Copy(gameDll, newTempPath);
newHandle = NativeLibrary.Load(newTempPath);
Log.InvalidateBacktraceCache();
var newCreate =
Marshal.GetDelegateForFunctionPointer<GameCreate>(NativeLibrary.GetExport(newHandle, "game_create"));
var newDestroy =
Expand All @@ -347,7 +348,10 @@ public void ReloadGame() {
toast_begin_application();
} catch (Exception ex) {
if (!adopted) {
if (newHandle != IntPtr.Zero) NativeLibrary.Free(newHandle);
if (newHandle != IntPtr.Zero) {
NativeLibrary.Free(newHandle);
Log.InvalidateBacktraceCache();
}
TryDeleteGameTemp(newTempPath);
}

Expand Down Expand Up @@ -451,6 +455,7 @@ private string FindGameDll() {

private void LoadFrom(string dllPath) {
m_gameHandle = NativeLibrary.Load(dllPath);
Log.InvalidateBacktraceCache();
m_gameTempPath = dllPath;
m_gameCreate =
Marshal.GetDelegateForFunctionPointer<GameCreate>(NativeLibrary.GetExport(m_gameHandle, "game_create"));
Expand All @@ -472,6 +477,7 @@ private void ReleaseGameLibraries() {
}

m_retiredGameLibraries.Clear();
Log.InvalidateBacktraceCache();
}

private static void TryDeleteGameTemp(string path) {
Expand Down
6 changes: 6 additions & 0 deletions editor/Logger/LogCsv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace editor.Logger;

// Mirrors the CSV format written by the log_server
internal static class LogCsv {
public const string Header = "Timestamp,Severity,Filepath,Line,Sink,Message,Details,Backtrace";

private static readonly string[] s_severityNames = ["TRACE", "INFO", "WARNING", "ERROR", "CRITICAL"];

private static readonly SearchValues<char> s_mustQuote = SearchValues.Create(",\"\r\n");
Expand All @@ -33,6 +35,10 @@ public static string ToCsvLine(LogEntry entry) {
AppendField(sb, entry.Sink);
sb.Append(',');
AppendField(sb, entry.Message);
sb.Append(',');
AppendField(sb, entry.Details);
sb.Append(',');
AppendField(sb, entry.Backtrace);
return sb.ToString();
}

Expand Down
58 changes: 51 additions & 7 deletions editor/Logger/LogDetailWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
x:DataType="vm:LogEntry"
Width="700"
MinHeight="260"
MaxHeight="640"
MaxHeight="900"
SizeToContent="Height"
CanResize="False"
CanMaximize="False"
Expand Down Expand Up @@ -39,7 +39,8 @@
<Border Background="{Binding Severity, Converter={StaticResource SeverityBarColorConverter}}"
Width="6"
Height="28"
CornerRadius="3" />
CornerRadius="3"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding SeverityName}"
FontFamily="FiraCode Nerd Font,Consolas,monospace"
FontWeight="Bold"
Expand All @@ -61,18 +62,22 @@
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="Timestamp"
VerticalAlignment="Center"
Foreground="{StaticResource TextMuted}" />
<TextBlock Grid.Row="0"
Grid.Column="1"
Text="{Binding AbsoluteTimestamp}"
VerticalAlignment="Center"
FontFamily="FiraCode Nerd Font,Consolas,monospace" />
<TextBlock Grid.Row="1"
Grid.Column="0"
Text="File"
VerticalAlignment="Center"
Foreground="{StaticResource TextMuted}" />
<TextBlock Grid.Row="1"
Grid.Column="1"
Text="{Binding FileLine}"
VerticalAlignment="Center"
FontFamily="FiraCode Nerd Font,Consolas,monospace"
TextWrapping="Wrap" />
</Grid>
Expand All @@ -81,17 +86,56 @@
CornerRadius="8"
Padding="8"
MaxHeight="300">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>
<SelectableTextBlock Text="{Binding Message}"
TextWrapping="Wrap"
FontFamily="FiraCode Nerd Font,Consolas,monospace"
Foreground="{StaticResource Text}" />
<Border Background="{StaticResource Bg2}"
Height="3"
Width="150"
CornerRadius="100"
IsVisible="{Binding HasDetails}"
Margin="0, 8, 0, 4"/>
<SelectableTextBlock Text="{Binding Details}"
IsVisible="{Binding HasDetails}"
TextWrapping="Wrap"
FontFamily="FiraCode Nerd Font,Consolas,monospace"
Foreground="{StaticResource TextMuted}" />
</StackPanel>
</ScrollViewer>
</Border>

<Border Background="{StaticResource Bg1}"
CornerRadius="8"
Padding="8"
MaxHeight="240"
IsVisible="{Binding HasBacktrace}">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<SelectableTextBlock Text="{Binding Message}"
<SelectableTextBlock Text="{Binding Backtrace}"
TextWrapping="Wrap"
FontFamily="FiraCode Nerd Font,Consolas,monospace"
Foreground="{StaticResource Text}" />
</ScrollViewer>
</Border>

<Grid ColumnDefinitions="*,Auto,Auto,Auto"
<Grid ColumnDefinitions="*,Auto,Auto,Auto,Auto"
ColumnSpacing="8">
<Button Grid.Column="1"
Click="OnCopyBacktrace"
IsVisible="{Binding HasBacktrace}"
CornerRadius="6"
Background="{StaticResource Bg4}"
HorizontalContentAlignment="Center">
<StackPanel Orientation="Horizontal"
Spacing="4">
<LucideIcon Kind="Layers"
Size="16"
StrokeWidth="2.5" />
<TextBlock Text="Copy backtrace" />
</StackPanel>
</Button>
<Button Grid.Column="2"
Click="OnCopyMessage"
CornerRadius="6"
Background="{StaticResource Bg4}"
Expand All @@ -104,7 +148,7 @@
<TextBlock Text="Copy message" />
</StackPanel>
</Button>
<Button Grid.Column="2"
<Button Grid.Column="3"
Click="OnCopy"
CornerRadius="6"
Background="{StaticResource Bg4}"
Expand All @@ -117,7 +161,7 @@
<TextBlock Text="Copy" />
</StackPanel>
</Button>
<Button Grid.Column="3"
<Button Grid.Column="4"
Classes="primary"
Click="OnClose"
CornerRadius="6"
Expand Down
5 changes: 5 additions & 0 deletions editor/Logger/LogDetailWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ private async void OnCopyMessage(object? sender, RoutedEventArgs e) {
await clipboard.SetTextAsync(entry.Message);
}

private async void OnCopyBacktrace(object? sender, RoutedEventArgs e) {
if (Entry is { } entry && Clipboard is { } clipboard)
await clipboard.SetTextAsync(entry.Backtrace);
}

private void OnClose(object? sender, RoutedEventArgs e) {
Close();
}
Expand Down
Loading
Loading