File tree 3 files changed +4
-26
lines changed
src/Agent/NewRelic/Agent/Core/Logging
tests/Agent/UnitTests/Core.UnitTest/Logging
3 files changed +4
-26
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ public static class AuditLog
12
12
// a lazy ILogger instance that injects an "Audit" property
13
13
private static Lazy < ILogger > _lazyAuditLogger = LazyAuditLogger ( ) ;
14
14
15
- public static bool IsAuditLogEnabled { get ; set ; } //setter is public only for unit tests, not expected to be use anywhere else
15
+ public static bool IsAuditLogEnabled { get ; set ; }
16
16
17
17
// for unit tests only
18
18
public static void ResetLazyLogger ( )
@@ -38,15 +38,11 @@ public static void Log(string message)
38
38
39
39
public static LoggerConfiguration IncludeOnlyAuditLog ( this LoggerConfiguration loggerConfiguration )
40
40
{
41
- IsAuditLogEnabled = true ; // set a flag so Log() can short-circuit when audit log is not enabled
42
-
43
41
return loggerConfiguration . Filter . ByIncludingOnly ( $ "{ LogLevelExtensions . AuditLevel } is not null") ;
44
42
}
45
43
46
44
public static LoggerConfiguration ExcludeAuditLog ( this LoggerConfiguration loggerConfiguration )
47
45
{
48
- IsAuditLogEnabled = false ; // set a flag so Log() can short-circuit when audit log is not enabled
49
-
50
46
return loggerConfiguration . Filter . ByIncludingOnly ( $ "{ LogLevelExtensions . AuditLevel } is null") ;
51
47
}
52
48
}
Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ public static void ConfigureLogger(ILogConfig config)
57
57
{
58
58
SetupLogLevel ( config ) ;
59
59
60
+ AuditLog . IsAuditLogEnabled = config . IsAuditLogEnabled ;
61
+
60
62
var loggerConfig = new LoggerConfiguration ( )
61
63
. MinimumLevel . ControlledBy ( _loggingLevelSwitch )
62
64
. ConfigureAuditLogSink ( config )
Original file line number Diff line number Diff line change 1
- // Copyright 2020 New Relic, Inc. All rights reserved.
1
+ // Copyright 2020 New Relic, Inc. All rights reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
4
using NUnit . Framework ;
@@ -30,26 +30,6 @@ public void TearDown()
30
30
AuditLog . ResetLazyLogger ( ) ;
31
31
}
32
32
33
- [ Test ]
34
- public void IncludeOnlyAuditLog_EnablesAuditLog ( )
35
- {
36
- Assert . False ( AuditLog . IsAuditLogEnabled ) ;
37
-
38
- var _ = new LoggerConfiguration ( ) . IncludeOnlyAuditLog ( ) ;
39
-
40
- Assert . True ( AuditLog . IsAuditLogEnabled ) ;
41
- }
42
-
43
- [ Test ]
44
- public void ExcludeAuditLog_DisablesAuditLog ( )
45
- {
46
- AuditLog . IsAuditLogEnabled = true ;
47
-
48
- var _ = new LoggerConfiguration ( ) . ExcludeAuditLog ( ) ;
49
-
50
- Assert . False ( AuditLog . IsAuditLogEnabled ) ;
51
- }
52
-
53
33
[ TestCase ( true ) ]
54
34
[ TestCase ( false ) ]
55
35
public void Log_OnlyLogsWhenAuditLogEnabled ( bool logEnabled )
You can’t perform that action at this time.
0 commit comments