Skip to content

Commit 22747d8

Browse files
Add logging support 🔊
1 parent bc97ff5 commit 22747d8

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using Microsoft.Extensions.Logging;
3+
4+
namespace Notion.Client
5+
{
6+
internal static class Log
7+
{
8+
internal static ILogger logger;
9+
10+
internal static void Trace(string message, params object[] args)
11+
{
12+
logger?.LogTrace(message, args);
13+
}
14+
15+
internal static void Information(string message, params object[] args)
16+
{
17+
logger?.LogInformation(message, args);
18+
}
19+
20+
internal static void Error(Exception ex, string message, params object[] args)
21+
{
22+
logger?.LogError(ex, message, args);
23+
}
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.Extensions.Logging;
2+
3+
namespace Notion.Client
4+
{
5+
public static class NotionClientLogging
6+
{
7+
internal static ILoggerFactory factory;
8+
9+
public static void ConfigureLogger(ILoggerFactory loggerFactory)
10+
{
11+
factory = loggerFactory;
12+
13+
Log.logger = Log.logger == null ? factory?.CreateLogger("Notion.Client") : Log.logger;
14+
}
15+
}
16+
}

‎Src/Notion.Client/Notion.Client.csproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
</PackageReference>
2323
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2424
<PackageReference Include="JsonSubTypes" Version="1.8.0" />
25+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0"/>
2526
</ItemGroup>
2627

2728
<ItemGroup>

0 commit comments

Comments
 (0)