Skip to content

Commit 41ac4a3

Browse files
MaxTube-dotadmin
andauthored
source gen logging (#163)
* Issues 147 Go at source gen logging * Issues 147 Go at source gen logging --------- Co-authored-by: admin <[email protected]>
1 parent 3f71a74 commit 41ac4a3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Infrastructure/HydraScript.Infrastructure/LoggingWriter.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33

44
namespace HydraScript.Infrastructure;
55

6-
internal class LoggingWriter(ILogger<LoggingWriter> logger) : IOutputWriter
6+
internal partial class LoggingWriter(ILogger<LoggingWriter> logger) : IOutputWriter
77
{
8-
public void WriteLine(object? obj) =>
9-
logger.LogInformation("{Object}", obj);
8+
[LoggerMessage(
9+
EventId = 0,
10+
Level = LogLevel.Information,
11+
Message = "{obj}")]
12+
public partial void WriteLine(object? obj);
1013

11-
public void WriteError(Exception e, string message) =>
12-
logger.LogError(e, "{Message}", message);
14+
[LoggerMessage(
15+
EventId = 1,
16+
Level = LogLevel.Error,
17+
Message = "{message}")]
18+
public partial void WriteError(Exception e, string message);
1319
}

0 commit comments

Comments
 (0)