Godot.Logging
1.2.0
dotnet add package Godot.Logging --version 1.2.0
NuGet\Install-Package Godot.Logging -Version 1.2.0
<PackageReference Include="Godot.Logging" Version="1.2.0" />
paket add Godot.Logging --version 1.2.0
#r "nuget: Godot.Logging, 1.2.0"
// Install Godot.Logging as a Cake Addin #addin nuget:?package=Godot.Logging&version=1.2.0 // Install Godot.Logging as a Cake Tool #tool nuget:?package=Godot.Logging&version=1.2.0
Godot Logging Library
A C# logging library for the Godot game engine. The library provides several Log Targets needed to log messages in a variety of formats. This is intended to work with the .NET version of Godot (C#). The latest NuGet packages provide targets for .NET 6, .NET 7, and .NET 8.
Version Compatibility
Different versions of Godot.Logging may support different version of the Godot SDK. See below.
Godot.Logging v1.2.* → Godot SDK 4.2.2 or greater
Godot.Logging v1.1.* → Godot SDK 4.0.2 or greater
Usage
Overview
Logging can be configured for use in just a few lines of code.
// Create a configuration for the logger
LogConfiguration config = new LogConfiguration();
config.RegisterTarget(new GDPrintTarget("GodotConsole"));
// Set the configuration
GodotLogger.SetConfiguration(config);
// Start logging messages!
GodotLogger.LogInfo("Hello Godot!");
Logging Exceptions
Exceptions may be logged as well.
try
{
throw new Exception(exMsg);
}
catch (Exception ex)
{
GodotLogger.LogException(ex, "An exception occurred.");
}
When logging excpetions, if preferred, the whole stack trace can be outputted in the log with the following setting.
GodotLogger.Instance.Configuration.IncludeExceptionCallStack = true;
Format Rules
Formatting rules (output format in the log) may be specified. In the LogConfiguration, you may specify 1 format rule per log level.
FormatRule infoRule = new FormatRule()
{
FormatText = "[${level}][${classname}.${methodname}] ${message}",
FormatLogLevel = LogLevel.Info
};
GodotLogger.Instance.Configuration.ApplyFormattingRule(infoRule);
As seen above, format rules may include macros to indicate parts of the format to be replace with log entry specific information. Here are the current macros that are supported.
${level} - Log level associated with the log entry.
${classname} - Class or type name of the object from where the log entry was invoked.
${methodname} - Name of the method within the object from where the log entry was invoked.
${message} - The actual message recorded for the log entry / event.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
-
net6.0
- Godot.SourceGenerators (>= 4.2.2)
- GodotSharp (>= 4.2.2)
-
net7.0
- Godot.SourceGenerators (>= 4.2.2)
- GodotSharp (>= 4.2.2)
-
net8.0
- Godot.SourceGenerators (>= 4.2.2)
- GodotSharp (>= 4.2.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Godot.Logging:
Package | Downloads |
---|---|
Godot.Console
A console/logging backend for Godot 4 (C#). |
GitHub repositories
This package is not used by any popular GitHub repositories.