org.slf4j.Logger.isDebugEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(625)

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

Logger.isDebugEnabled介绍

[英]Is the logger instance enabled for the DEBUG level?
[中]是否为调试级别启用了记录器实例?

代码示例

代码示例来源:origin: spring-projects/spring-framework

public void debug(Object message) {
  if (message instanceof String || this.logger.isDebugEnabled()) {
    this.logger.debug(String.valueOf(message));
  }
}

代码示例来源:origin: skylot/jadx

public void printMissingClasses() {
    int count = missingClasses.size();
    if (count == 0) {
      return;
    }
    LOG.warn("Found {} references to unknown classes", count);
    if (LOG.isDebugEnabled()) {
      List<String> clsNames = new ArrayList<>(missingClasses);
      Collections.sort(clsNames);
      for (String cls : clsNames) {
        LOG.debug("  {}", cls);
      }
    }
  }
}

代码示例来源:origin: apache/hive

static void logException(String msg, Exception e) {
 if (LOG.isDebugEnabled()) {
  LOG.debug(msg, e);
 } else {
  LOG.info(msg + ": " + e.getMessage());
 }
}

代码示例来源:origin: apache/hive

private void addCredentials(ReduceWork reduceWork, DAG dag) {
 Set<URI> fileSinkUris = new HashSet<URI>();
 List<Node> topNodes = new ArrayList<Node>();
 topNodes.add(reduceWork.getReducer());
 collectFileSinkUris(topNodes, fileSinkUris);
 if (LOG.isDebugEnabled()) {
  for (URI fileSinkUri: fileSinkUris) {
   LOG.debug("Marking ReduceWork output URI as needing credentials: " + fileSinkUri);
  }
 }
 dag.addURIsForCredentials(fileSinkUris);
}

代码示例来源:origin: apache/hbase

private void stopUsingCurrentWriter() {
  if (currentWriter != null) {
   if (LOG.isDebugEnabled()) {
    LOG.debug("Stopping to use a writer after [" + Bytes.toString(currentWriterEndKey)
      + "] row; wrote out " + cellsInCurrentWriter + " kvs");
   }
   cellsInCurrentWriter = 0;
  }
  currentWriter = null;
  currentWriterEndKey =
    (existingWriters.size() + 1 == boundaries.size()) ? null : boundaries.get(existingWriters
      .size() + 1);
 }
}

代码示例来源:origin: alibaba/fescar

private void printMergeMessageLog(MergedWarpMessage mergeMessage) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("merge msg size:" + mergeMessage.msgIds.size());
      for (AbstractMessage cm : mergeMessage.msgs) { LOGGER.debug(cm.toString()); }
      StringBuffer sb = new StringBuffer();
      for (long l : mergeMessage.msgIds) { sb.append(MSG_ID_PREFIX).append(l).append(SINGLE_LOG_POSTFIX); }
      sb.append("\n");
      for (long l : futures.keySet()) { sb.append(FUTURES_PREFIX).append(l).append(SINGLE_LOG_POSTFIX); }
      LOGGER.debug(sb.toString());
    }
  }
}

代码示例来源:origin: alibaba/fescar

@Override
public void onCheckMessage(long msgId, ChannelHandlerContext ctx, ServerMessageSender sender) {
  try {
    sender.sendResponse(msgId, ctx.channel(), HeartbeatMessage.PONG);
  } catch (Throwable throwable) {
    LOGGER.error("", "send response error", throwable);
  }
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("received PING from " + ctx.channel().remoteAddress());
  }
}

代码示例来源:origin: apache/flink

@Override
public void initializeState(StateInitializationContext context) throws Exception {
  super.initializeState(context);
  checkState(checkpointedState == null,    "The reader state has already been initialized.");
  checkpointedState = context.getOperatorStateStore().getSerializableListState("splits");
  int subtaskIdx = getRuntimeContext().getIndexOfThisSubtask();
  if (context.isRestored()) {
    LOG.info("Restoring state for the {} (taskIdx={}).", getClass().getSimpleName(), subtaskIdx);
    // this may not be null in case we migrate from a previous Flink version.
    if (restoredReaderState == null) {
      restoredReaderState = new ArrayList<>();
      for (TimestampedFileInputSplit split : checkpointedState.get()) {
        restoredReaderState.add(split);
      }
      if (LOG.isDebugEnabled()) {
        LOG.debug("{} (taskIdx={}) restored {}.", getClass().getSimpleName(), subtaskIdx, restoredReaderState);
      }
    }
  } else {
    LOG.info("No state to restore for the {} (taskIdx={}).", getClass().getSimpleName(), subtaskIdx);
  }
}

代码示例来源:origin: apache/pulsar

@Override
protected void handleGetTopicsOfNamespaceSuccess(CommandGetTopicsOfNamespaceResponse success) {
  checkArgument(state == State.Ready);
  long requestId = success.getRequestId();
  List<String> topics = success.getTopicsList();
  if (log.isDebugEnabled()) {
    log.debug("{} Received get topics of namespace success response from server: {} - topics.size: {}",
      ctx.channel(), success.getRequestId(), topics.size());
  }
  CompletableFuture<List<String>> requestFuture = pendingGetTopicsRequests.remove(requestId);
  if (requestFuture != null) {
    requestFuture.complete(topics);
  } else {
    log.warn("{} Received unknown request id from server: {}", ctx.channel(), success.getRequestId());
  }
}

代码示例来源:origin: apache/flink

@Override
public void initializeState(FunctionInitializationContext context) throws Exception {
  Preconditions.checkArgument(this.restoredBucketStates == null,
    "The " + getClass().getSimpleName() + " has already been initialized.");
  try {
    initFileSystem();
  } catch (IOException e) {
    LOG.error("Error while creating FileSystem when initializing the state of the RollingSink.", e);
    throw new RuntimeException("Error while creating FileSystem when initializing the state of the RollingSink.", e);
  }
  if (this.refTruncate == null) {
    this.refTruncate = reflectTruncate(fs);
  }
  OperatorStateStore stateStore = context.getOperatorStateStore();
  restoredBucketStates = stateStore.getSerializableListState("rolling-states");
  int subtaskIndex = getRuntimeContext().getIndexOfThisSubtask();
  if (context.isRestored()) {
    LOG.info("Restoring state for the {} (taskIdx={}).", getClass().getSimpleName(), subtaskIndex);
    for (BucketState bucketState : restoredBucketStates.get()) {
      handleRestoredBucketState(bucketState);
    }
    if (LOG.isDebugEnabled()) {
      LOG.debug("{} (taskIdx= {}) restored {}", getClass().getSimpleName(), subtaskIndex, bucketState);
    }
  } else {
    LOG.info("No state to restore for the {} (taskIdx= {}).", getClass().getSimpleName(), subtaskIndex);
  }
}

代码示例来源:origin: apache/geode

@Override
protected void rebalanceCache() {
 try {
  getLogger().info("Rebalancing: " + this.cache);
  RebalanceResults results = RegionHelper.rebalanceCache(this.cache);
  if (getLogger().isDebugEnabled()) {
   getLogger().debug("Done rebalancing: " + this.cache);
   getLogger().debug(RegionHelper.getRebalanceResultsMessage(results));
  }
 } catch (Exception e) {
  getLogger().warn("Rebalance failed because of the following exception:", e);
 }
}

代码示例来源:origin: resilience4j/resilience4j

@Override
public void onSubscribe(Subscription s) {
  if (LOG.isDebugEnabled()) {
    LOG.info("onSubscribe");
  }
  sa.setSubscription(s);
}

代码示例来源:origin: apache/nifi

void expire(final FlowFile flowFile, final String details) {
  try {
    final ProvenanceEventRecord record = build(flowFile, ProvenanceEventType.EXPIRE).setDetails(details).build();
    events.add(record);
  } catch (final Exception e) {
    logger.error("Failed to generate Provenance Event due to " + e);
    if (logger.isDebugEnabled()) {
      logger.error("", e);
    }
  }
}

代码示例来源:origin: apache/kafka

/**
 * Queue a call for sending.
 *
 * If the AdminClient thread has exited, this will fail. Otherwise, it will succeed (even
 * if the AdminClient is shutting down). This function should called when retrying an
 * existing call.
 *
 * @param call      The new call object.
 * @param now       The current time in milliseconds.
 */
void enqueue(Call call, long now) {
  if (log.isDebugEnabled()) {
    log.debug("Queueing {} with a timeout {} ms from now.", call, call.deadlineMs - now);
  }
  boolean accepted = false;
  synchronized (this) {
    if (newCalls != null) {
      newCalls.add(call);
      accepted = true;
    }
  }
  if (accepted) {
    client.wakeup(); // wake the thread if it is in poll()
  } else {
    log.debug("The AdminClient thread has exited. Timing out {}.", call);
    call.fail(Long.MAX_VALUE, new TimeoutException("The AdminClient thread has exited."));
  }
}

代码示例来源:origin: apache/hive

private static boolean[] pickStripesInternal(SearchArgument sarg, int[] filterColumns,
  List<StripeStatistics> stripeStats, int stripeCount, Path filePath,
  final SchemaEvolution evolution) {
 boolean[] includeStripe = new boolean[stripeCount];
 for (int i = 0; i < includeStripe.length; ++i) {
  includeStripe[i] = (i >= stripeStats.size()) ||
    isStripeSatisfyPredicate(stripeStats.get(i), sarg, filterColumns, evolution);
  if (LOG.isDebugEnabled() && !includeStripe[i]) {
   LOG.debug("Eliminating ORC stripe-" + i + " of file '" + filePath
     + "'  as it did not satisfy predicate condition.");
  }
 }
 return includeStripe;
}

代码示例来源:origin: apache/flink

@Override
  public InputSplit getNextInputSplit(String host, int taskId) {
    InputSplit next = null;
    
    // keep the synchronized part short
    synchronized (this.splits) {
      if (this.splits.size() > 0) {
        next = this.splits.remove(this.splits.size() - 1);
      }
    }
    
    if (LOG.isDebugEnabled()) {
      if (next == null) {
        LOG.debug("No more input splits available");
      } else {
        LOG.debug("Assigning split " + next + " to " + host);
      }
    }
    return next;
  }
}

代码示例来源:origin: micronaut-projects/micronaut-core

private void logException(Throwable cause) {
  //handling connection reset by peer exceptions
  if (cause instanceof IOException && IGNORABLE_ERROR_MESSAGE.matcher(cause.getMessage()).matches()) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Swallowed an IOException caused by client connectivity: " + cause.getMessage(), cause);
    }
  } else {
    if (LOG.isErrorEnabled()) {
      LOG.error("Unexpected error occurred: " + cause.getMessage(), cause);
    }
  }
}

代码示例来源:origin: apache/nifi

@Override
public Response toResponse(NoConnectedNodesException ex) {
  // log the error
  logger.info(String.format("Cluster failed processing request: %s. Returning %s response.", ex, Response.Status.INTERNAL_SERVER_ERROR));
  if (logger.isDebugEnabled()) {
    logger.debug(StringUtils.EMPTY, ex);
  }
  return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("Action was performed, but no nodes are connected.").type("text/plain").build();
}

代码示例来源:origin: perwendel/spark

/**
 * Trigger a browser redirect
 *
 * @param location Where to redirect
 */
public void redirect(String location) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Redirecting ({} {} to {}", "Found", HttpServletResponse.SC_FOUND, location);
  }
  try {
    response.sendRedirect(location);
  } catch (IOException ioException) {
    LOG.warn("Redirect failure", ioException);
  }
}

代码示例来源:origin: spring-projects/spring-framework

public void debug(Object message, Throwable exception) {
  if (message instanceof String || this.logger.isDebugEnabled()) {
    this.logger.debug(String.valueOf(message), exception);
  }
}

相关文章