File tree 1 file changed +44
-0
lines changed
1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ using Azure . DataApiBuilder . Config ;
5
+ using Azure . DataApiBuilder . Config . ObjectModel ;
6
+ using Azure . DataApiBuilder . Core . Configurations ;
7
+ using Microsoft . Extensions . Logging ;
8
+ using static Azure . DataApiBuilder . Config . DabConfigEvents ;
9
+
10
+ namespace Azure . DataApiBuilder . Service . Telemetry
11
+ {
12
+ public class LogLevelInitializer
13
+ {
14
+ private RuntimeConfigProvider ? _runtimeConfigProvider ;
15
+ private string _loggerFilter ;
16
+
17
+ public LogLevel MinLogLevel { get ; private set ; }
18
+
19
+ public LogLevelInitializer ( LogLevel logLevel , string loggerFilter , HotReloadEventHandler < HotReloadEventArgs > ? handler )
20
+ {
21
+ handler ? . Subscribe ( LOG_LEVEL_INITIALIZER_ON_CONFIG_CHANGE , OnConfigChanged ) ;
22
+ MinLogLevel = logLevel ;
23
+ _loggerFilter = loggerFilter ;
24
+ }
25
+
26
+ public void SetLogLevel ( )
27
+ {
28
+ if ( _runtimeConfigProvider ! . TryGetConfig ( out RuntimeConfig ? runtimeConfig ) )
29
+ {
30
+ MinLogLevel = RuntimeConfig . GetConfiguredLogLevel ( runtimeConfig , _loggerFilter ) ;
31
+ }
32
+ }
33
+
34
+ public void SetRuntimeConfigProvider ( RuntimeConfigProvider configProvider )
35
+ {
36
+ _runtimeConfigProvider = configProvider ;
37
+ }
38
+
39
+ private void OnConfigChanged ( object ? sender , HotReloadEventArgs args )
40
+ {
41
+ SetLogLevel ( ) ;
42
+ }
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments