Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Zlogger throws exception when using Unity Editor Playback Options

Kevdome3000 opened this issue · comments

Hey there,

Just an observation, but I'm using a Global logging manager like the example provided in the Readme, and I get NullReference errors when stopping and re-entering play mode.

Here is an example stack trace:

[Exception] NullReferenceException: Object reference not set to an instance of an object
ZLoggerExtensions.ZLogInformation() at Library/PackageCache/com.cysharp.zlogger@1.5.0/ZLoggerExtensions.cs:4757
4755:   public static void ZLogInformation(this ILogger logger, EventId eventId, Exception exception, string message)
4756:   {
-->4757:       logger.Log(LogLevel.Information, eventId, new MessageLogState<object>(null, message), exception, (state, ex) =>
4758:       {
4759:           return state.Message;

ZLoggerExtensions.ZLogInformation() at Library/PackageCache/com.cysharp.zlogger@1.5.0/ZLoggerExtensions.cs:4742
4740:   public static void ZLogInformation(this ILogger logger, string message)
4741:   {
-->4742:       ZLogInformation(logger, default(EventId), default(Exception), message);
4743:   }

AppManager.Start() at /XXXX/Managers/App/AppManager.cs:84
82:   public void Start()
83:   {
-->84:       _logger.ZLogInformation("----- AppManager Initialized");
86:       // userContainer.SetActive(true);

Maybe this is expected, but it would be cool if it worked with the editor play options.

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.