File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed
src/SplunkLogger/Providers Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Concurrent ;
3
3
using System . Collections . Generic ;
4
+ using System . Diagnostics ;
4
5
using System . Linq ;
5
6
using System . Net . Http ;
6
7
using System . Net . Http . Headers ;
@@ -89,7 +90,15 @@ public void Emit(List<object> events)
89
90
var jArray = events . Select ( evt => JsonConvert . SerializeObject ( evt , Formatting . None ) ) ;
90
91
var formatedMessage = string . Join ( " " , jArray ) ;
91
92
var stringContent = new StringContent ( formatedMessage , Encoding . UTF8 , "application/json" ) ;
92
- httpClient . PostAsync ( string . Empty , stringContent ) ;
93
+ httpClient . PostAsync ( string . Empty , stringContent )
94
+ . ContinueWith ( task => {
95
+ if ( task . IsCompletedSuccessfully )
96
+ Debug . WriteLine ( "Splunk HEC RAW Status: Sucess" ) ;
97
+ else if ( task . IsCanceled )
98
+ Debug . WriteLine ( "Splunk HEC RAW Status: Canceled" ) ;
99
+ else
100
+ Debug . WriteLine ( "Splunk HEC RAW Status: Error " + task . Exception != null ? task . Exception . ToString ( ) : "" ) ;
101
+ } ) ;
93
102
}
94
103
}
95
104
}
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Collections . Concurrent ;
2
3
using System . Collections . Generic ;
4
+ using System . Diagnostics ;
5
+ using System . Linq ;
3
6
using System . Net . Http ;
4
7
using System . Net . Http . Headers ;
5
8
using Microsoft . Extensions . Logging ;
6
- using System . Linq ;
7
- using System . Collections . Concurrent ;
8
9
using Splunk . Configurations ;
9
10
using Splunk . Loggers ;
10
11
@@ -86,7 +87,15 @@ public void Emit(List<object> events)
86
87
{
87
88
var formatedMessage = string . Join ( Environment . NewLine , events . Select ( evt => evt . ToString ( ) ) ) ;
88
89
var stringContent = new StringContent ( formatedMessage ) ;
89
- httpClient . PostAsync ( string . Empty , stringContent ) ;
90
+ httpClient . PostAsync ( string . Empty , stringContent )
91
+ . ContinueWith ( task => {
92
+ if ( task . IsCompletedSuccessfully )
93
+ Debug . WriteLine ( "Splunk HEC RAW Status: Sucess" ) ;
94
+ else if ( task . IsCanceled )
95
+ Debug . WriteLine ( "Splunk HEC RAW Status: Canceled" ) ;
96
+ else
97
+ Debug . WriteLine ( "Splunk HEC RAW Status: Error " + task . Exception != null ? task . Exception . ToString ( ) : "" ) ;
98
+ } ) ;
90
99
}
91
100
}
92
101
}
You can’t perform that action at this time.
0 commit comments