File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 16
16
17
17
using OSharp . AspNetCore ;
18
18
using OSharp . Core . Packs ;
19
+ using OSharp . Reflection ;
19
20
20
21
21
22
namespace Microsoft . AspNetCore . Builder
@@ -31,12 +32,14 @@ public static class ApplicationBuilderExtensions
31
32
public static IApplicationBuilder UseOSharp ( this IApplicationBuilder app )
32
33
{
33
34
IServiceProvider provider = app . ApplicationServices ;
34
- ILogger logger = provider . GetLogger ( typeof ( ApplicationBuilderExtensions ) ) ;
35
- logger . LogInformation ( "OSharp框架初始化开始" ) ;
35
+ ILogger logger = provider . GetLogger ( " ApplicationBuilderExtensions" ) ;
36
+ logger . LogInformation ( 0 , "OSharp框架初始化开始" ) ;
36
37
Stopwatch watch = Stopwatch . StartNew ( ) ;
37
38
OsharpPack [ ] packs = provider . GetAllPacks ( ) ;
38
39
foreach ( OsharpPack pack in packs )
39
40
{
41
+ string packName = pack . GetType ( ) . GetDescription ( ) ;
42
+ logger . LogInformation ( $ "正在初始化模块 “{ packName } ”") ;
40
43
if ( pack is AspOsharpPack aspPack )
41
44
{
42
45
aspPack . UsePack ( app ) ;
@@ -45,10 +48,11 @@ public static IApplicationBuilder UseOSharp(this IApplicationBuilder app)
45
48
{
46
49
pack . UsePack ( provider ) ;
47
50
}
51
+ logger . LogInformation ( $ "模块 “{ packName } ” 初始化完成") ;
48
52
}
49
53
50
54
watch . Stop ( ) ;
51
- logger . LogInformation ( $ "OSharp框架初始化完成,耗时:{ watch . Elapsed } ") ;
55
+ logger . LogInformation ( 0 , $ "OSharp框架初始化完成,耗时:{ watch . Elapsed } ") ;
52
56
53
57
return app ;
54
58
}
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ public void CreateMap()
77
77
CreateMap ( tuple . Source , tuple . Target ) ;
78
78
_logger . LogDebug ( $ "创建“{ tuple . Source } ”到“{ tuple . Target } ”的对象映射关系") ;
79
79
}
80
- _logger . LogInformation ( $ "创建 { tuples . Count } 个对象映射关系") ;
80
+ _logger . LogInformation ( $ "创建了 { tuples . Count } 个对象映射关系") ;
81
81
}
82
82
}
83
83
}
Original file line number Diff line number Diff line change @@ -17,13 +17,13 @@ public class Log4NetPack : OsharpPack
17
17
/// <summary>
18
18
/// 获取 模块级别,级别越小越先启动
19
19
/// </summary>
20
- public override PackLevel Level => PackLevel . Framework ;
20
+ public override PackLevel Level => PackLevel . Application ;
21
21
22
22
/// <summary>
23
23
/// 获取 模块启动顺序,模块启动的顺序先按级别启动,级别内部再按此顺序启动,
24
24
/// 级别默认为0,表示无依赖,需要在同级别有依赖顺序的时候,再重写为>0的顺序值
25
25
/// </summary>
26
- public override int Order => 1 ;
26
+ public override int Order => 0 ;
27
27
28
28
/// <summary>
29
29
/// 将模块服务添加到依赖注入服务容器中
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ public virtual void SubscribeAll(Type[] eventHandlerTypes)
125
125
EventStore . Add ( eventDataType , factory ) ;
126
126
Logger . LogDebug ( $ "创建事件“{ eventDataType } ”到处理器“{ eventHandlerType } ”的订阅配对") ;
127
127
}
128
- Logger . LogInformation ( $ "共从程序集创建了{ eventHandlerTypes . Length } 个事件处理器的事件订阅") ;
128
+ Logger . LogInformation ( $ "共从程序集创建了 { eventHandlerTypes . Length } 个事件处理器的事件订阅") ;
129
129
}
130
130
131
131
/// <summary>
You can’t perform that action at this time.
0 commit comments