Comments (3)
I had considered including them in LogInfo, but abandoned the idea due to compatibility issues with Source Generator. However, by handling them as string?, int?, string? in LogInfo and making them optional in Source Generator, it seems possible to implement this without any issues. Therefore, I'd like to consider adding them to the standard Log method.
from zlogger.
I've released 2.3.0, it includes this feature.
from zlogger.
Example of what I am currently doing:
[UnityEngine.HideInCallstack]
public static void Debug(
this ILogger logger,
[InterpolatedStringHandlerArgument("logger")] ref ZLoggerDebugInterpolatedStringHandler message,
UnityEngine.Object gameObject,
[CallerFilePath] string path = null,
[CallerLineNumber] int line = 0,
[CallerMemberName] string method = null)
{
if (logger.IsEnabled(LogLevel.Debug))
{
using var x = logger.BeginScope("{Caller}",Log.FormatCallerInfo(path, line, method));
logger.ZLogDebug(ref message, gameObject);
}
}
and then in PlainTextFormatter:
y.SetSuffixFormatter($"{0}", (message, info) =>
{
var sb = new StringBuilder();
if (info.ScopeState is { IsEmpty: false })
{
foreach (var pair in info.ScopeState.Properties)
{
if(pair.Key == "{OriginalFormat}")
continue;
sb.AppendLine();
sb.Append("| ");
sb.Append(pair.Key);
sb.Append(":");
if (pair.Value is StringValues stringValues)
sb.Append(stringValues.ToString());
else
sb.Append(pair.Value);
}
message.Format(sb.ToString());
}
}
from zlogger.
Related Issues (20)
- v2 release task
- Misuse HOT 5
- Improvement: Shared Files HOT 2
- Improvement: Add optional MessageCap HOT 2
- Make use of "Interceptors" feature from C# 12 (Experimental) HOT 3
- Possible symbol name collisions in generated code HOT 2
- Add Intermediate String Interpolater HOT 3
- Add native CLEF format json logging support HOT 7
- UnitLoggerFactory formatting problems with JSON messages HOT 4
- NuGet Clone failure in Unity With dotnet 4.8.1 HOT 5
- Dependency errors in Unity 2023.2 HOT 7
- Some AOT warning HOT 2
- MessageSequence's IEnumerable Handling Assumptions lead to erroneous serialization HOT 13
- NullReferenceException due to Key being Null in MagicalBox.ReaderCache HOT 9
- Exception output content with plain text is missing HOT 1
- Load Assembly faild in unity 2021.3.12(MacOs)/15(Win11) HOT 4
- FileLogger not Compatible with WebGL HOT 1
- Typo in the "about" text to the repository HOT 1
- IL2CPP build problem with UnityLoggerFactory HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zlogger.