1- using System ;
2- using System . Collections . Concurrent ;
1+ using System . Collections . Concurrent ;
32using System . Collections . Generic ;
4- using System . Diagnostics ;
53using System . Linq ;
64using System . Net . Http ;
7- using System . Net . Http . Headers ;
85using System . Text ;
96using Microsoft . Extensions . Logging ;
107using Newtonsoft . Json ;
@@ -85,48 +82,7 @@ public void Emit(List<object> events)
8582 var formatedMessage = string . Join ( " " , jArray ) ;
8683 var stringContent = new StringContent ( formatedMessage , Encoding . UTF8 , "application/json" ) ;
8784 httpClient . PostAsync ( string . Empty , stringContent )
88- . ContinueWith ( task => {
89- if ( task . IsCompletedSuccessfully )
90- switch ( task . Result . StatusCode )
91- {
92- case System . Net . HttpStatusCode . OK :
93- Debug . WriteLine ( "Splunk HEC JSON Status: Request completed successfully." ) ;
94- break ;
95- case System . Net . HttpStatusCode . Created :
96- Debug . WriteLine ( "Splunk HEC JSON Status: Create request completed successfully." ) ;
97- break ;
98- case System . Net . HttpStatusCode . BadRequest :
99- Debug . WriteLine ( "Splunk HEC JSON Status: Request error. See response body for details." ) ;
100- break ;
101- case System . Net . HttpStatusCode . Unauthorized :
102- Debug . WriteLine ( "Splunk HEC JSON Status: Authentication failure, invalid access credentials." ) ;
103- break ;
104- case System . Net . HttpStatusCode . PaymentRequired :
105- Debug . WriteLine ( "Splunk HEC JSON Status: In-use Splunk Enterprise license disables this feature." ) ;
106- break ;
107- case System . Net . HttpStatusCode . Forbidden :
108- Debug . WriteLine ( "Splunk HEC JSON Status: Insufficient permission." ) ;
109- break ;
110- case System . Net . HttpStatusCode . NotFound :
111- Debug . WriteLine ( "Splunk HEC JSON Status: Requested endpoint does not exist." ) ;
112- break ;
113- case System . Net . HttpStatusCode . Conflict :
114- Debug . WriteLine ( "Splunk HEC JSON Status: Invalid operation for this endpoint. See response body for details." ) ;
115- break ;
116- case System . Net . HttpStatusCode . InternalServerError :
117- Debug . WriteLine ( "Splunk HEC JSON Status: Unspecified internal server error. See response body for details." ) ;
118- break ;
119- case System . Net . HttpStatusCode . ServiceUnavailable :
120- Debug . WriteLine ( "Splunk HEC JSON Status: Feature is disabled in configuration file." ) ;
121- break ;
122- default :
123- break ;
124- }
125- else if ( task . IsCanceled )
126- Debug . WriteLine ( "Splunk HEC RAW Status: Canceled" ) ;
127- else
128- Debug . WriteLine ( "Splunk HEC RAW Status: Error " + task . Exception != null ? task . Exception . ToString ( ) : "" ) ;
129- } ) ;
85+ . ContinueWith ( task => DebugSplunkResponse ( task , "json" ) ) ;
13086 }
13187 }
13288}
0 commit comments