Skip to content

Commit 0aa2df3

Browse files
committed
feat: 增加日志初始化逻辑
1 parent 2a5ee54 commit 0aa2df3

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/extensions/BootstrapBlazor.TcpSocket/DefaultTcpSocketFactory.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

5+
using BootstrapBlazor.Components;
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Microsoft.Extensions.Logging;
58
using System.Collections.Concurrent;
69
using System.Runtime.Versioning;
710

@@ -14,6 +17,14 @@ sealed class DefaultTcpSocketFactory(IServiceProvider provider) : ITcpSocketFact
1417

1518
public ITcpSocketClient GetOrCreate(string name, Action<TcpSocketClientOptions> valueFactory)
1619
{
20+
if (!SocketLogging.Inited)
21+
{
22+
var logger = provider.GetService<ILogger<DefaultTcpSocketFactory>>();
23+
if (logger != null)
24+
{
25+
SocketLogging.Init(logger);
26+
}
27+
}
1728
return _pool.GetOrAdd(name, key =>
1829
{
1930
var options = new TcpSocketClientOptions();

0 commit comments

Comments
 (0)