Exemple #1
0
        private static LogMessageV1 ExtractLogMessage(AnyValueMap map)
        {
            var time          = map.GetAsDateTimeWithDefault("time", DateTime.UtcNow);
            var level         = map.GetAsEnum <LogLevel>("level");
            var source        = map.GetAsStringWithDefault("source", string.Empty);
            var correlationId = map.GetAsStringWithDefault("correlation_id", string.Empty);
            var error         = ExtractError(map.GetAsMap("error"));
            var message       = map.GetAsStringWithDefault("message", string.Empty);

            return(new LogMessageV1(time, level, source, correlationId, error, message));
        }
Exemple #2
0
        private static ErrorDescription ExtractError(AnyValueMap map)
        {
            if (map.Count == 0)
            {
                return(null);
            }

            var code        = map.GetAsStringWithDefault("code", string.Empty);
            var message     = map.GetAsStringWithDefault("message", string.Empty);
            var stack_trace = map.GetAsStringWithDefault("stack_trace", string.Empty);

            return(new ErrorDescription()
            {
                Code = code,
                Message = message,
                StackTrace = stack_trace
            });
        }