Item Drops

Logging and Observability

Overview

ItemDrops is designed to follow the same logging architecture as other gameplay plugins (GridBuilding, WorldTime):

  • Core logic uses a thin logging interface.
  • Backend implementations rely on Chickensoft.Log.
  • Godot (and other engine) specifics are owned by the host game.

This page describes how to integrate ItemDrops logging with your game and Godot.


Core Logging Contract

ItemDrops Core should expose a small logging interface (or adopt a shared one) such as:

public interface ILogger {
    void Info(string message);
    void Warn(string message);
    void Error(string message, Exception? ex = null);
}

Design rules:

  • No engine types in the interface.
  • Minimal, focused API.
  • Implementation can be swapped without modifying ItemDrops domain code.

Implementations in ItemDrops Core can:

  • Use Chickensoft.Log as the backend.
  • Use TestWriter in unit tests for verifying log output.

Godot Integration (Game-Level)

For a Godot game that consumes ItemDrops:

  1. Add logging dependencies

    • Reference Chickensoft.Log.
    • Optionally reference Chickensoft.Log.Godot.
  2. Implement the ItemDrops logging interface

    • Implement the interface in the game project.
    • Internally, route messages to a configured Chickensoft.Log.ILog instance.
    • Configure writers (TraceWriter, ConsoleWriter, Godot writers) as appropriate.
  3. Register via DI/services

    • Register your implementation so ItemDrops Core resolves it from DI.
  4. Use Godot UI errors where needed

    • Keep infrastructure logging in Chickensoft.Log.
    • Use GD.PushError / GD.PushWarning from Godot scripts to surface user-facing errors.

We recommend Chickensoft.Log.Godot as one option for adapting the ItemDrops logging interface to Godot:

  • Attach Godot-specific writers to your ILog instance.
  • Keep the ItemDrops plugin itself unaware of engine details.

By following this pattern, ItemDrops remains portable across engines while still providing good observability in Godot-based games.