Cysharp / ZLogger

Zero Allocation Text/Structured Logger for .NET with StringInterpolation and Source Generator, built on top of a Microsoft.Extensions.Logging.
MIT License
1.13k stars 80 forks source link

Add helper method to name parameter like `$”{(keyName, value)}` #92

Closed hadashiA closed 7 months ago

hadashiA commented 8 months ago

Add ZLogger.Param(keyName, value) helper. Let's give ValueTuple<string, T> special treatment.

It is for specifying the name of the parameter key for each ZLog call individually.

How to:

var id = 111;
logger.ZLogInformation($"......... {("userId",  id)} ........");

// plain text result
// #=> "......... 111 ........"

// json result
// #=> { "userId": 111, "Message": "......... 111 ........", ... }
neuecc commented 8 months ago

same name of namespace and class name is......

hadashiA commented 8 months ago

After discussion this, I remove ZLogger.Param, and fix up instead of used (string, T)...!