Beispiel #1
0
        private void logEnd(string sessionId, HttpRequest request, AnyResult result, Exception error)
        {
            var log = _log;

            var sb = new StringBuilder(1024);

            sb.Append($"{result.trackingId} >> ");

            if (error == null)
            {
                sb.Append(result.ToWireJson());
                log.Trace(sb.ToString());
                return;
            }

            var details = new {
                errorMessage = error.Message,
                sessionId,
                error.StackTrace,
                result,
                request = request.Dump(),
            };

            sb.Append(details.ToJson());
            log.Trace(sb.ToString());
        }
Beispiel #2
0
        private AnyResult newResult(string sessionId)
        {
            var result = new AnyResult {
                trackingId = AnyResultHelpers.GenerateTrackingId(sessionId),
                status     = HttpStatusCode.OK
            };

            return(result);
        }
Beispiel #3
0
        private void setErrorDetails(AnyResult result, Exception error, bool detailsOnError)
        {
            if (error == null)
            {
                return;
            }

            result.status = HttpStatusCode.InternalServerError;
            result.error  = new AnyResult.Error {
                message = $"Something went wrong ({result.trackingId})",
            };

            if (detailsOnError == false)
            {
                return;
            }

            result.error.message += $"; {error.Message}";
            result.error.details  = error.Data;
        }
Beispiel #4
0
 public static string ToJson(this AnyResult result)
 {
     return
         (JsonConvert.SerializeObject(result, Formatting.Indented, _jsonSettings));
 }
Beispiel #5
0
 public static string ToWireJson(this AnyResult result)
 {
     return
         (JsonConvert.SerializeObject(result, Formatting.None, _jsonSettings));
 }
Beispiel #6
0
        private void logStart(string sessionId, HttpRequest request, AnyResult result)
        {
            var log = _log;

            log.Trace($"{result.trackingId} << {request.RawUrl}");
        }