File tree Expand file tree Collapse file tree 4 files changed +44
-6
lines changed
test/Voxel.MiddyNet.Tests Expand file tree Collapse file tree 4 files changed +44
-6
lines changed Original file line number Diff line number Diff line change 5
5
</PropertyGroup >
6
6
7
7
<PropertyGroup Label =" MiddyNet Versions" >
8
- <middynet >1.3.0 $(VersionSuffix)</middynet >
8
+ <middynet >1.3.1 $(VersionSuffix)</middynet >
9
9
</PropertyGroup >
10
10
</Project >
Original file line number Diff line number Diff line change @@ -69,10 +69,18 @@ private void InternalLog(LogMessage logMessage)
69
69
70
70
private void AddLambdaContextProperties ( )
71
71
{
72
- globalProperties . Add ( new LogProperty ( "AwsRequestId" , lambdaContext . AwsRequestId ) ) ;
73
- globalProperties . Add ( new LogProperty ( "FunctionName" , lambdaContext . FunctionName ) ) ;
74
- globalProperties . Add ( new LogProperty ( "FunctionVersion" , lambdaContext . FunctionVersion ) ) ;
75
- globalProperties . Add ( new LogProperty ( "MemoryLimitInMB" , lambdaContext . MemoryLimitInMB ) ) ;
72
+ AddOrReplaceProperty ( "AwsRequestId" , lambdaContext . AwsRequestId ) ;
73
+ AddOrReplaceProperty ( "FunctionName" , lambdaContext . FunctionName ) ;
74
+ AddOrReplaceProperty ( "FunctionVersion" , lambdaContext . FunctionVersion ) ;
75
+ AddOrReplaceProperty ( "MemoryLimitInMB" , lambdaContext . MemoryLimitInMB ) ;
76
+ }
77
+
78
+ private void AddOrReplaceProperty ( string name , object value )
79
+ {
80
+ var index = globalProperties . FindIndex ( p => p . Key == name ) ;
81
+ if ( index != - 1 ) globalProperties . RemoveAt ( index ) ;
82
+
83
+ globalProperties . Add ( new LogProperty ( name , value ) ) ;
76
84
}
77
85
}
78
86
Original file line number Diff line number Diff line change
1
+ {
2
+ "Message": "hello world",
3
+ "Level": "Debug",
4
+ "AwsRequestId": "12345",
5
+ "FunctionName": "FunctionName",
6
+ "FunctionVersion": "1.0",
7
+ "MemoryLimitInMB": 1024
8
+ }{
9
+ "Message": "hello world",
10
+ "Level": "Debug",
11
+ "AwsRequestId": "12345",
12
+ "FunctionName": "FunctionName",
13
+ "FunctionVersion": "1.0",
14
+ "MemoryLimitInMB": 1024
15
+ }
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public class MiddyLoggerShould
21
21
22
22
public MiddyLoggerShould ( )
23
23
{
24
- lambdaLogger . Log ( Arg . Do < string > ( a => receivedLog = a ) ) ;
24
+ lambdaLogger . Log ( Arg . Do < string > ( a => receivedLog + = a ) ) ;
25
25
lambdaContext . AwsRequestId . Returns ( AwsRequestId ) ;
26
26
lambdaContext . FunctionName . Returns ( FunctionName ) ;
27
27
lambdaContext . FunctionVersion . Returns ( FunctionVersion ) ;
@@ -80,10 +80,25 @@ public void LogGlobalPropertiesAndExtraProperties()
80
80
Approvals . Verify ( receivedLog ) ;
81
81
}
82
82
83
+ [ Fact ]
84
+ public void LogTwiceWithNoErrors ( )
85
+ {
86
+ var logger = new MiddyLogger ( lambdaLogger , lambdaContext ) ;
87
+ logger . Log ( LogLevel . Debug , "hello world" ) ;
88
+ logger . Log ( LogLevel . Debug , "hello world" ) ;
89
+
90
+ Approvals . Verify ( receivedLog ) ;
91
+ }
92
+
83
93
internal class ClassToLog
84
94
{
85
95
public string Property1 { get ; set ; }
86
96
public string Property2 { get ; set ; }
87
97
}
98
+
99
+ ~ MiddyLoggerShould ( )
100
+ {
101
+ receivedLog = string . Empty ;
102
+ }
88
103
}
89
104
}
You can’t perform that action at this time.
0 commit comments