Chirp - Unity Logging

Logging, in general a simple piece of code that is quite often overlooked at the beginning of any project can become a powerful tool when debugging or testing the game.

Quite often we'll use Debug.Log() to inform ourselves about state changes in internal systems, add it to drop us a line in the console with the result of a RPC call, or, when all other ideas fail - add it every 3 lines in a long method to find where that NullReferenceException without a detailed Stack Trace occurs.

And sooner or later we end up in the same place... too many logs, not enough, where it came from, where is that one that I'm actually looking for...

That is why I decided to create Chirp - Unity Logging - a Unity focused extendable logging framework.

Features

You can read all about the features on the GitHub page but the main goals of the framework are

  • to integrate with some of the popular runtime consoles,
  • to allow for easy extension of log handling,
  • to allow for adding context to logs in a much easier way.

Integration

Thanks to the fact that Chirp integrates with default Unity Console most runtime consoles will have no problem with showing the logs.

Currently I'm preparing an additional integration package for Quantum Console to allow for better filtering and detailed preview.

Extensions

Under the hood Chirp is a simple Log event processor that uses custom Loggers to format and process any data you send through it.

By default it comes with UnityConsoleLogger which integrates with the default Unity Console and handles any default calls to Debug.Log() methods.

You can write custom loggers and process the log data however you please from saving it to disk to sending it off to a server.

Context - Log Channels

Chirp allows you to easily add context to your logs by the means of Log Channels which are added to the logged message.

// simple string channel
Chirp.Log("CustomManager", "Manager has been initialised");

// output: [CustomManager] Manager has been initialised
Simple log message

You can also define a class as Log Channel Target and it will be automatically picked up in the stack trace to be set as the channel.

This also allows us to add channels to any calls of Debug.Log() as Chirp replaces the default handler and any defined targets will be displayed as Log Channels. If none are found it will be added a default "Unity" channel.

[LogChannel]
public class PlayerController : MonoBehaviour
{
	private void Start()
	{
		Debug.Log("Player Controller started");
		// output: [PlayerController] Player Controller started
	}
}

public class EnemyController : MonoBehaviour
{
	private void Start()
	{
		Debug.Log("Enemy Controller started");
		// output: [Unity] Enemy Controller Started
	}
}
Automated Log Channels through class attribute.

The attribute based Log Channels need to be generated ahead of time to remove any requirement for Reflection. The generator is run from Tools/Chirp Logger/Generate Log Channels List.

Continued development

The first release composes of the basic functionality, there are more custom loggers and integrations planned.
If you find any bugs or have ideas for additional features please report them on the repository Issues page.

Feedback is greatly appreciated!