Skip to content

JakubSlaby/Chirp

Repository files navigation

Chirp - Unity Logging

Overview

Simple Unity logging framework easily exandable for custom functionality

  • Log Channels for easy message categorisation
  • Customisable Loggers allow for custom processing
  • Default Unity console integration

Installation

Best way to install Chirp is to download the latest package from Releases, full source code is included in the UnityPackage. Import the package in to your Unity project through Assets/Import Package/Custom Package.

Initialisation through a component

To quickly initialise the logging framework you can create a Chirp Initializer game object in your scene. Simply go to Tools/Chirp Logger/Create Initializer Object.

Log Example

Enable the available loggers (by default it comes with UnityConsoleLogger) and enjoy!

Initialisation From Code

The framework needs to be enabled for each desired target platform through the settings window. You can find it by opening Tools/Chirp Framework/Chirp Settings or by navigating directly to Project Settings window.

To initialize the framework in runtime you can call Chirp.Initialize() anywhere from your code.

Chirp.Initialize(new UnityConsoleLogger(), new QuantumConsoleLogger());

Examples use an additional integration with AssetStore packages: Quantum Console, SRDebugger

Or use the Chirp Initializer GameObject Component to do that automatically. You can create it through Tools/Chirp Logger/Create Initializer Object.

Logging

The default log API with simple message and stack trace functionality.

Chirp.Debug("Debug Message"); // Detailed logs, best for cases like logging rpc responses or method outputs.
Chirp.Log("Log Message"); // Typical log message, most common use case.
Chirp.Info("Info Message"); // State change or any significant message that would have less detailed data.
Chirp.Warning("Warning Message");
Chirp.Error("Error message");
Chirp.Exception(new Exception(), "Exception Message");

Log Example

Channels

Add Log Channel identifier for specifying the source or context of the log so that it's easily recognisable in console.

Chirp.DebugCh("Inventory","Debug Message");
Chirp.LogCh("ConnectionResolver", "Log Message");
Chirp.InfoCh("SaveManager", "Info Message");
Chirp.WarningCh("PlayerController","Warning Message");
Chirp.ErrorCh("SaveManager","Error message");
Chirp.ExceptionCh( "PlayerController", new Exception(), "Exception Message");

Log Example

Quantum Console needs aditional integration for custom formatting, filtering and Stack Trace lookups.
SRDebugger has built in filtering by text.

Automatic channels

You can automatically detect channels based on class Types that are found in the stack trace. To tag a type as a LogChannel all you need to do is add the [LogChannel] attribute and generate list of channels.

[LogChannel]
public class PlayerController
{
  // ...
}

After you change which types are tagged with the [LogChannel] attribute, you will need to generate a helper class that will hold the list. You can find the list generator under Tools/Chirp Logger/Generate Log Channels List menu.

Conditional Compilation

All chirp logging API methods are compiled conditionally and controlled through Player Script Define Symbols. If Chirp is disabled for given platform any calls to the API will be automatically skipped when compiling - this allows for easy changing of log levels and compiled features without the need to remove your own code.

You can easily adjust the settings through the Chirp Logging Framework Project settings (Tools/Chirp Logging/Chirp Settings). Log Example

Integrations

Thanks to it's simple structure Chirp Logging is highly customisable. Most extensions relying on the default Console will work out of the box.

Quantum Console Integration

I have prepared additional integration with Quantum Console allowing for more detailed information, filtering and search. The full upgrade instructions will be published soon.

Contributing

If you find any issues or think there are missing features that could benefit the package please use GitHub Issues to report any bugs or ideas.

Twitch Status Twitter Follow

About

Chirp Logging Framework is designed to make handling console logs much easier, add context and extend the default functions added by Unity's Debug.Log classes.

Topics

Resources

License

Stars

Watchers

Forks

Languages