コード例 #1
0
        internal void CreateResponseData(HttpContext context, string responseBody, DateTimeOffset end, IServerlessLogger serverlessLogger)
        {
            Response = new LogApiResponse();

            EndTimestamp        = end;
            Response.Body       = LoggerHelper.ConvertToJson(responseBody, serverlessLogger);
            Response.StatusCode = (context?.Response?.StatusCode).GetValueOrDefault();
            Response.Headers    = context?.Response?.Headers?.ToDictionary(h => h.Key, h => h.Value);
        }
コード例 #2
0
        internal void CreateRequestData(HttpContext context, string requestBody, DateTimeOffset start, IServerlessLogger serverlessLogger)
        {
            Request = new LogApiRequest();

            StartTimestamp  = start;
            Request.Body    = LoggerHelper.ConvertToJson(requestBody, serverlessLogger);
            Request.Method  = context?.Request?.Method;
            Request.Url     = $"{context?.Request.Scheme}://{context?.Request.Host}{context?.Request.Path.ToString()}";
            Request.Headers = context?.Request?.Headers?.ToDictionary(h => h.Key, h => h.Value);
        }
コード例 #3
0
 private object CreateLog(
     DateTimeOffset startProcess,
     DateTimeOffset endProcess,
     HttpRequestMessage request,
     HttpResponseMessage response,
     string requestText,
     string responseText)
 {
     return(new
     {
         type = "Third Party",
         date = DateTimeOffset.UtcNow,
         authUserId = transactionFlow.Id,
         clientId = transactionFlow.ClientId,
         customerId = transactionFlow.CustomerId,
         customerDocument = transactionFlow.CustomerDocument,
         startTimestamp = startProcess,
         endTimestamp = endProcess,
         duration = Convert.ToDecimal(Math.Round((endProcess - startProcess).TotalMilliseconds, 2, MidpointRounding.AwayFromZero)),
         culture = transactionFlow.Culture,
         url = request.RequestUri.AbsoluteUri,
         machine = transactionFlow.Machine,
         hostIp = transactionFlow.HostIp,
         localIp = transactionFlow.LocalIp,
         serviceType = "rest",
         request = new
         {
             body = LoggerHelper.ConvertToJson(requestText, serverlessLogger),
             method = request.Method.Method,
             headers = request.Headers.ToDictionary(h => h.Key, h => h.Value),
         },
         response = new
         {
             body = LoggerHelper.ConvertToJson(responseText, serverlessLogger),
             headers = response.Headers.ToDictionary(h => h.Key, h => h.Value),
             isSuccessStatusCode = response.IsSuccessStatusCode,
             statusCode = response.StatusCode.GetHashCode(),
         },
         method = request.Method.Method,
         hasError = !response.IsSuccessStatusCode,
     });
 }