示例#1
0
 protected virtual async Task RecordFailedMessageAsync(LambdaLogLevel level, string body, Exception exception)
 {
     if (!string.IsNullOrEmpty(_deadLetterQueueUrl))
     {
         await _sqsClient.SendMessageAsync(_deadLetterQueueUrl, body);
     }
     else
     {
         LogWarn("dead letter queue not configured");
         throw new LambdaFunctionException("dead letter queue not configured", exception);
     }
 }
示例#2
0
        private void Log(LambdaLogLevel level, Exception exception, string format, params object[] args)
        {
            string message = RollbarClient.FormatMessage(format, args);

            Log(level, $"{message}", exception?.ToString());
            if (level >= LambdaLogLevel.WARNING)
            {
                if (_rollbarEnabled)
                {
                    try {
                        Log(LambdaLogLevel.INFO, "rollbar sending data", extra: null);
                        var result = _rollbarClient.SendAsync(level.ToString(), exception, format, args).Result;
                        if (!result.IsSuccess)
                        {
                            Log(LambdaLogLevel.ERROR, $"Rollbar payload request failed. {result.Message}. UUID: {result.UUID}", extra: null);
                        }
                    } catch (Exception e) {
                        Log(LambdaLogLevel.ERROR, "rollbar SendAsync exception", e.ToString());
                    }
                }
                else if (_loggingTopicArn != null)
                {
                    string payload;
                    try {
                        // send exception to error-topic
                        payload = _rollbarClient.CreatePayload(MAX_SNS_SIZE, level.ToString(), exception, format, args);
                    } catch (Exception e) {
                        Log(LambdaLogLevel.ERROR, "rollbar CreatePayload exception", e.ToString());
                        return;
                    }
                    try {
                        // send exception to error-topic
                        _snsClient.PublishAsync(new PublishRequest {
                            TopicArn = _loggingTopicArn,
                            Message  = payload
                        }).Wait();
                    } catch (Exception e) {
                        Log(LambdaLogLevel.ERROR, "SNS publish exception", e.ToString());
                        Log(LambdaLogLevel.INFO, "logging payload", payload);
                    }
                }
            }
        }
 /// <summary>
 /// Log a message wit the given severity level. The <c>format</c> string is used to create a unique signature for errors.
 /// Therefore, any error information that varies between occurrences should be provided in the <c>arguments</c> parameter.
 /// </summary>
 /// <remarks>
 /// Nothing is logged if both <paramref name="format"/> and <paramref name="exception"/> are null.
 /// </remarks>
 /// <param name="level">The severity level of the log message. See <see cref="LambdaLogLevel"/> for a description of the severity levels.</param>
 /// <param name="exception">Optional exception to log. The exception is logged with its description and stacktrace. This parameter can be <c>null</c>.</param>
 /// <param name="format">Optional message to use instead of <c>Exception.Message</c>. This parameter can be <c>null</c>.</param>
 /// <param name="arguments">Optional arguments for the <c>format</c> parameter.</param>
 public void Log(LambdaLogLevel level, Exception exception, string format, params object[] arguments)
 => AppClient.Log(level, exception, format, arguments);
示例#4
0
 public void Log(LambdaLogLevel level, Exception exception, string format, params object[] arguments)
 {
 }
示例#5
0
 private void Log(LambdaLogLevel level, string message, string extra)
 => LambdaLogger.Log($"*** {level.ToString().ToUpperInvariant()}: {message} [{Stopwatch.Elapsed:c}]\n{extra}");