software.amazon.awssdk.utils.Logger.error()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中software.amazon.awssdk.utils.Logger.error()方法的一些代码示例,展示了Logger.error()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.error()方法的具体详情如下:
包路径:software.amazon.awssdk.utils.Logger
类名称:Logger
方法名:error

Logger.error介绍

[英]Checks if error is enabled and if so logs the supplied message
[中]检查是否启用了错误,如果启用,则记录提供的消息

代码示例

代码示例来源:origin: aws/aws-sdk-java-v2

public final void run(String[] args) {
  Options options = new Options();
  Stream.of(optionsToAdd).forEach(options::addOption);
  CommandLineParser parser = new DefaultParser();
  HelpFormatter help = new HelpFormatter();
  try {
    CommandLine commandLine = parser.parse(options, args);
    run(commandLine);
  } catch (ParseException e) {
    log.error(() -> "Invalid input: " + e.getMessage());
    help.printHelp(getClass().getSimpleName(), options);
    throw new Error();
  } catch (Exception e) {
    log.error(() -> "Script execution failed.", e);
    throw new Error();
  }
}

代码示例来源:origin: aws/aws-sdk-java-v2

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
  boolean channelInUse = getAttribute(ctx, ChannelAttributeKey.IN_USE).orElse(false);
  if (channelInUse) {
    ctx.fireExceptionCaught(cause);
  } else {
    ctx.close();
    Optional<CompletableFuture<Void>> executeFuture = getAttribute(ctx, ChannelAttributeKey.EXECUTE_FUTURE_KEY);
    if (executeFuture.isPresent() && !executeFuture.get().isDone()) {
      log.error(() -> "An exception occurred on an channel (" + ctx.channel().id() + ") that was not in use, " +
              "but was associated with a future that wasn't completed. This indicates a bug in the " +
              "Java SDK, where a future was not completed while the channel was in use. The channel has " +
              "been closed, and the future will be completed to prevent any ongoing issues.", cause);
      executeFuture.get().completeExceptionally(cause);
    } else if (cause instanceof IOException) {
      log.debug(() -> "An I/O exception (" + cause.getMessage() + ") occurred on a channel (" + ctx.channel().id() +
              ") that was not in use. The channel has been closed. This is usually normal.");
    } else {
      log.warn(() -> "A non-I/O exception occurred on a channel (" + ctx.channel().id() + ") that was not in use. " +
              "The channel has been closed to prevent any ongoing issues.", cause);
    }
  }
}

代码示例来源:origin: software.amazon.awssdk/netty-nio-client

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
  boolean channelInUse = getAttribute(ctx, ChannelAttributeKey.IN_USE).orElse(false);
  if (channelInUse) {
    ctx.fireExceptionCaught(cause);
  } else {
    ctx.close();
    Optional<CompletableFuture<Void>> executeFuture = getAttribute(ctx, ChannelAttributeKey.EXECUTE_FUTURE_KEY);
    if (executeFuture.isPresent() && !executeFuture.get().isDone()) {
      log.error(() -> "An exception occurred on an channel (" + ctx.channel().id() + ") that was not in use, " +
              "but was associated with a future that wasn't completed. This indicates a bug in the " +
              "Java SDK, where a future was not completed while the channel was in use. The channel has " +
              "been closed, and the future will be completed to prevent any ongoing issues.", cause);
      executeFuture.get().completeExceptionally(cause);
    } else if (cause instanceof IOException) {
      log.debug(() -> "An I/O exception (" + cause.getMessage() + ") occurred on a channel (" + ctx.channel().id() +
              ") that was not in use. The channel has been closed. This is usually normal.");
    } else {
      log.warn(() -> "A non-I/O exception occurred on a channel (" + ctx.channel().id() + ") that was not in use. " +
              "The channel has been closed to prevent any ongoing issues.", cause);
    }
  }
}

代码示例来源:origin: software.amazon.awssdk/sdk-core

} catch (IOException deletionException) {
  Logger.loggerFor(ResponseTransformer.class)
     .error(() -> "Failed to delete destination file '" + path +
            "' after reading the service response " +
            "failed.", deletionException);

相关文章

微信公众号

最新文章

更多