Beispiel #1
0
 /// <summary>
 /// Sends to log.
 /// </summary>
 /// <param name="logMetadata">The log metadata.</param>
 /// <returns></returns>
 private async Task <bool> SendToLog(LogMetadata logMetadata)
 {
     if ((AppSettings.Instance.TraceType == TraceType.NoSwaggerDelegationHandler) && (logMetadata.RequestUri.ToLower().Contains("swagger")))
     {
         return(true);
     }
     _logger.Trace(logMetadata.AsString());
     return(true);
 }
Beispiel #2
0
 /// <summary></summary>
 private LogMetadata BuildResponseMetadata(LogMetadata logMetadata, HttpResponseMessage response)
 {
     logMetadata.ResponseStatusCode  = response.StatusCode;
     logMetadata.ResponseTimestamp   = DateTime.UtcNow;
     logMetadata.ResponseContentType = response.Content.Headers.ContentType.MediaType;
     if (response.Content != null)
     {
         logMetadata.ResponseContent = response.Content.ReadAsStringAsync().Result;
     }
     return(logMetadata);
 }
Beispiel #3
0
        /// <summary></summary>
        private LogMetadata BuildRequestMetadata(HttpRequestMessage request)
        {
            LogMetadata log = new LogMetadata
            {
                RequestMethod    = request.Method.Method,
                RequestTimestamp = DateTime.UtcNow,
                RequestUri       = request.RequestUri.ToString()
            };

            if (request.Content != null)
            {
                log.RequestContent = request.Content.ReadAsStringAsync().Result;
            }
            return(log);
        }