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 11using System ;
22using System . Collections . Concurrent ;
33using System . Collections . Generic ;
4+ using System . Diagnostics ;
45using System . Linq ;
56using System . Net . Http ;
67using System . Net . Http . Headers ;
@@ -89,7 +90,15 @@ public void Emit(List<object> events)
8990 var jArray = events . Select ( evt => JsonConvert . SerializeObject ( evt , Formatting . None ) ) ;
9091 var formatedMessage = string . Join ( " " , jArray ) ;
9192 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+ } ) ;
93102 }
94103 }
95104}
Original file line number Diff line number Diff line change 11using System ;
2+ using System . Collections . Concurrent ;
23using System . Collections . Generic ;
4+ using System . Diagnostics ;
5+ using System . Linq ;
36using System . Net . Http ;
47using System . Net . Http . Headers ;
58using Microsoft . Extensions . Logging ;
6- using System . Linq ;
7- using System . Collections . Concurrent ;
89using Splunk . Configurations ;
910using Splunk . Loggers ;
1011
@@ -86,7 +87,15 @@ public void Emit(List<object> events)
8687 {
8788 var formatedMessage = string . Join ( Environment . NewLine , events . Select ( evt => evt . ToString ( ) ) ) ;
8889 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+ } ) ;
9099 }
91100 }
92101}
You can’t perform that action at this time.
0 commit comments