OwofGames.GodotLogger 0.1.5

dotnet add package OwofGames.GodotLogger --version 0.1.5
                    
NuGet\Install-Package OwofGames.GodotLogger -Version 0.1.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OwofGames.GodotLogger" Version="0.1.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OwofGames.GodotLogger" Version="0.1.5" />
                    
Directory.Packages.props
<PackageReference Include="OwofGames.GodotLogger" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OwofGames.GodotLogger --version 0.1.5
                    
#r "nuget: OwofGames.GodotLogger, 0.1.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OwofGames.GodotLogger@0.1.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OwofGames.GodotLogger&version=0.1.5
                    
Install as a Cake Addin
#tool nuget:?package=OwofGames.GodotLogger&version=0.1.5
                    
Install as a Cake Tool

Godot Logger Provider

NuGet Version

This project serves as a base to hook Microsoft's logging infrastructure to the Godot console.

Use this project if you have C# components that rely on ILogger / ILoggerProvider / etc... and want them to output their logs to the Godot console, or you want to take advantage of the fine-grained, extensible architecture of Microsoft's logging system.

Quickstart

Add the NuGet package OwofGames.GodotLogger and Microsoft.Extensions.Logging to the Godot C# Project.

Then, during the initialization of your game, create the logger factory with something like this:

// Create the logger factory.
var loggerFactory = LoggerFactory.Create(builder => builder
    // This is the line that actually adds the Godot logger provider.
    // The argument is optional, but allows you to change the defaults.
    .AddGodot(configuration => configuration
        .SetLogLevelColor(LogLevel.Critical, Colors.MediumPurple)
        .SetLogLevelBold(LogLevel.Critical, true))
    // Further configuration, where you can add more logger providers or define logging rules.
    .SetMinimumLevel(LogLevel.Trace)
    .AddFilter("YourNamespace", LogLevel.Warning)
    .AddFilter("OtherNamespace", LogLevel.Trace)
);

Once you have this, you can inject the created logger factory in your DI container, expose it some other way, or use it directly:

var myLogger = loggerFactory.CreateLogger<MyClass>()

If you now print some stuff, like:

myLogger.LogTrace("This is a trace.");
myLogger.LogDebug("This is a debug.");
myLogger.LogInformation("This is an information.");
myLogger.LogWarning("This is a warning.");
myLogger.LogError("This is an error.");
myLogger.LogCritical("This is critical.");

You will see something like this in console

Godot's output window, showing "MyClass - This is a trace." in italic, then similar lines for "debug" (not italic, like the rest of them), "information", "warning" (in yellow), "error" (in red) and "critical" (in purple, and bold)

And something like this in the Debugger ⇒ Errors tab:

Error panel window, showing "MyClass - This is a warning" as a warning, same for error and critical (as errors), and in all three cases a line inside GodotLogger.Log as the source of the log

Note well: for filtering purposes, the logger provider has been assigned the "Godot" alias too.

Configuration

When adding the Godot logger to the factory builder, you can configure the way logs are produced on it:

var loggerFactory = LoggerFactory.Create(builder => builder 
    // ...
    .AddGodot(configuration => configuration
        .SetLogLevelColor(LogLevel.Critical, Colors.MediumPurple)
        .SetLogLevelBold(LogLevel.Critical, true)
        // more settings...
    )
    // ...
);

What follows is the API supported by GodotLoggerConfiguration (the configuration object above).

SetLogLevelColor(LogLevel logLevel, Color color), SetLogLevelBold(LogLevel logLevel, bool isBold),

SetLogLevelItalic(LogLevel logLevel, bool isItalic)

These methods overwrite the default color, bold or italic status for a specific log level.

Default values are:

Log Level Color Bold Italic
Trace DimGray false true
Debug DimGray false false
Information DarkGray false false
Warning Yellow false false
Error LightCoral false false
Critical Red false false

SetGodotLoggerMessageFormatter

This method provides two overloads to format the message string. If no formatter is provided, the format will be a simple category - message. The output on the Debugger tab always has this format and cannot be changed.

SetMessageFormatter(SimpleGodotLoggerMessageFormatter messageFormatter)

This overload uses an interpolated string to describe the log message format. For example:

using E = OwofGames.GodotLogger.SimpleGodotLoggerMessageFormatterElement;

// ...

configuration
    .SetMessageFormatter($"[ {E.Timestamp,17:yy/MM/dd HH.mm.ss} | {E.LogLevel,11} ] {E.Category} - {E.Message}");

Which would produce log lines like these:

[ 26/07/05 15.07.13 | Information ] LoggingButton - Writing an information message - 0
[ 26/07/05 15.07.13 | Information ] LoggingButton - Writing an information message - 1
[ 26/07/05 15.07.14 |       Trace ] LoggingButton - Writing a trace message - 2
[ 26/07/05 15.07.15 |       Debug ] LoggingButton - Writing a debug message - 3

The interpolated parts of this string must be elements of the enum OwofGames.GodotLogger.SimpleGodotLoggerMessageFormatterElement. Each of these elements can be formatted using the tools of C# string formatting, according to the type of the corresponding log element:

  • LogLevel: enum
  • Category, Message: string
  • EventId, State, Exception: object
  • TimeStamp: DateTime

Note well: if your IDE offers some kind of autocompletion for the formatting of these elements, they could always be aligned to what "enum" supports, which is generally wrong.

SetGodotLoggerMessageFormatter(IGodotLoggerMessageFormatter messageFormatter)

Define the logging format by explicitly providing an IGodotLoggerMessageFormatter. The object must implement the given interface, which requires a single method:

void Format<TState>(
    StringBuilder stringBuilder,
    DateTime timestamp,
    LogLevel logLevel,
    string category,
    EventId eventId,
    TState state,
    Exception? exception,
    Func<string> getMessage 
);

This method must write the message in the string builder passed as the first argument. All the information about the method is passed in the following parameters.

The actual log message is computed by the getMessage parameter.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OwofGames.GodotLogger:

Package Downloads
OwofGames.GodotHost

A package that offers configuration, logging and DI to Godot, based in Microsoft packages, in a similar way to that of Microsoft.Extensions.Hosting.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.5 119 7/10/2026
0.1.4 136 7/8/2026
0.1.2 91 7/5/2026
0.1.1 92 7/4/2026
0.1.0 94 7/4/2026