Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

Install via UPM

Add to Unity Package Manager using this URL

https://www.pkglnk.dev/detailed-logs.git

README Markdown

Copy this to your project's README.md

Style
Preview
pkglnk installs badge
## Installation

Add **Detailed Logs** to your Unity project via Package Manager:

1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/detailed-logs.git
```

[![pkglnk](https://www.pkglnk.dev/badge/detailed-logs.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/detailed-logs)

README

Overview

Default Unity log

Default Unity Log

Prettier Unity log

Prettier Log

Why This Package?

I don't like dependencies on third party packages - or depdencies at all for that matter.

The only reason you will ever need to reference this package in your code is if you want to make a custom log filter and even those are pretty light weight.

Quick Start

Install (UPM)

  1. In Unity, open the Package Manager
    Window > Package Management > Package Manager

  2. Install Package from git URL
    Package Manager > + (in top left) > Install Package from git URL

  3. Paste https://github.com/JohnnyHowe/unity-detailed-logs.git and press Install

(Recommended) If you want a specific version, use
https://github.com/JohnnyHowe/unity-detailed-logs.git#<version>

Usage

The logger will automatically override the default at runtime. No configuration needed.

Custom Configuration

Assets > Create > Detailed Log Configuration
Ensure this file is in a Resources folder and that there is only one.

Jon todo:
  • Ensure file is automatically put into Assets/Resources
  • Give warning/error when user tries to create a second

This file lets you adjust how and when the detailed logger takes over.

Configuration File Screenshot

Log Filtering

The detailed logger can handle filtering out logs based on.

  • Caller
  • Log content
  • Log type

To create a filter, have a class inherit from JonathonOH.Unity.DetailedLogs.DetailedLogFilter and call RegisterFilter onstartup.

Jon todo:
  • Make registering easier
  • Make filter an interface, not an abstract class

Example:

public class ExampleLogFilter : DetailedLogFilter
{
	/// <summary>
	/// Registers the filter in the logger
	/// </summary>
	[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
	private static void CreateFilterObject()
	{
		RegisterFilter(new ExampleLogFilter());
	}

	/// <summary>
	/// Hide Debug.Log statements from MyNamespace.MyClassThatIWantToHideLogsFor
	/// </summary>
	public override bool ShouldHideLog(Type caller, LogType logType, string format)
	{
		// Don't filter if we don't know caller
		if (caller == null)
		{
			return false;
		}

		// Only filter Debug.Logs
		if (logType != LogType.Log)
		{
			return false;
		}

		// Hide logs for a given class
		return caller.FullName.StartsWith("MyNamespace.MyClassThatIWantToHideLogsFor");
	}
}

Comments

No comments yet. Be the first!