com.metamx.common.logger.Logger.warn()方法的使用及代码示例

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

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

Logger.warn介绍

[英]Protect against assuming slf4j convention. use warn(Throwable t, String message, Object... formatArgs) instead
[中]防止采用slf4j公约。使用“warn(Throwable t,String message,Object…formatArgs)”代替

代码示例

代码示例来源:origin: io.druid.extensions/druid-rabbitmq

@Override
 public void shutdownCompleted(ShutdownSignalException cause)
 {
  log.warn(cause, "Connection closed!");
 }
}

代码示例来源:origin: io.druid.extensions/druid-rabbitmq

@Override
 public void shutdownCompleted(ShutdownSignalException cause)
 {
  log.warn(cause, "Channel closed!");
 }
}

代码示例来源:origin: com.n3twork.druid/druid-server

@Override
 public void stop()
 {
  try {
   server.stop();
  }
  catch (Exception e) {
   log.warn(e, "Unable to stop Jetty server.");
  }
 }
}

代码示例来源:origin: com.metamx/http-client

private long getReadTimeout(Duration requestReadTimeout)
{
 final long timeout;
 if (requestReadTimeout != null) {
  timeout = requestReadTimeout.getMillis();
 } else if (defaultReadTimeout != null) {
  timeout = defaultReadTimeout.getMillis();
 } else {
  timeout = 0;
 }
 if (timeout > 0 && timer == null) {
  log.warn("Cannot time out requests without a timer! Disabling timeout for this request.");
  return 0;
 } else {
  return timeout;
 }
}

代码示例来源:origin: com.metamx/java-util

@Override
 public InputStream nextElement()
 {
  try {
   return queue.take();
  }
  catch (InterruptedException e) {
   log.warn(e, "Thread interrupted while taking from queue");
   Thread.currentThread().interrupt();
   throw Throwables.propagate(e);
  }
 }
}

代码示例来源:origin: com.metamx/http-client

@Override
 public InputStream nextElement()
 {
  try {
   return queue.take();
  }
  catch (InterruptedException e) {
   log.warn(e, "Thread interrupted while taking from queue");
   Thread.currentThread().interrupt();
   throw Throwables.propagate(e);
  }
 }
}

代码示例来源:origin: metamx/java-util

@Override
 public InputStream nextElement()
 {
  try {
   return queue.take();
  }
  catch (InterruptedException e) {
   log.warn(e, "Thread interrupted while taking from queue");
   Thread.currentThread().interrupt();
   throw Throwables.propagate(e);
  }
 }
}

代码示例来源:origin: com.metamx/java-util

@Override
public void returnResource()
{
 if (returned.getAndSet(true)) {
  log.warn(String.format("Resource at key[%s] was returned multiple times?", key));
 } else {
  holder.giveBack(value);
 }
}

代码示例来源:origin: com.metamx/http-client

@Override
public void returnResource()
{
 if (returned.getAndSet(true)) {
  log.warn(String.format("Resource at key[%s] was returned multiple times?", key));
 } else {
  holder.giveBack(value);
 }
}

代码示例来源:origin: metamx/java-util

@Override
public void returnResource()
{
 if (returned.getAndSet(true)) {
  log.warn(String.format("Resource at key[%s] was returned multiple times?", key));
 } else {
  holder.giveBack(value);
 }
}

代码示例来源:origin: com.metamx/java-util

@Override
 protected void finalize() throws Throwable
 {
  if (!returned.get()) {
   log.warn(
     String.format(
       "Resource[%s] at key[%s] was not returned before Container was finalized, potential resource leak.",
       value,
       key
     )
   );
   returnResource();
  }
  super.finalize();
 }
};

代码示例来源:origin: metamx/java-util

@Override
 protected void finalize() throws Throwable
 {
  if (!returned.get()) {
   log.warn(
     String.format(
       "Resource[%s] at key[%s] was not returned before Container was finalized, potential resource leak.",
       value,
       key
     )
   );
   returnResource();
  }
  super.finalize();
 }
};

代码示例来源:origin: metamx/java-util

private static void awaitNextRetry(final Throwable e, final int nTry, final boolean quiet) throws InterruptedException
 {
  final long baseSleepMillis = 1000;
  final long maxSleepMillis = 60000;
  final double fuzzyMultiplier = Math.min(Math.max(1 + 0.2 * ThreadLocalRandom.current().nextGaussian(), 0), 2);
  final long sleepMillis = (long) (Math.min(maxSleepMillis, baseSleepMillis * Math.pow(2, nTry - 1))
                   * fuzzyMultiplier);
  if (quiet) {
   log.debug(e, "Failed on try %d, retrying in %,dms.", nTry, sleepMillis);
  } else {
   log.warn(e, "Failed on try %d, retrying in %,dms.", nTry, sleepMillis);
  }
  Thread.sleep(sleepMillis);
 }
}

代码示例来源:origin: com.metamx/java-util

private static void awaitNextRetry(final Throwable e, final int nTry, final boolean quiet) throws InterruptedException
 {
  final long baseSleepMillis = 1000;
  final long maxSleepMillis = 60000;
  final double fuzzyMultiplier = Math.min(Math.max(1 + 0.2 * ThreadLocalRandom.current().nextGaussian(), 0), 2);
  final long sleepMillis = (long) (Math.min(maxSleepMillis, baseSleepMillis * Math.pow(2, nTry - 1))
                   * fuzzyMultiplier);
  if (quiet) {
   log.debug(e, "Failed on try %d, retrying in %,dms.", nTry, sleepMillis);
  } else {
   log.warn(e, "Failed on try %d, retrying in %,dms.", nTry, sleepMillis);
  }
  Thread.sleep(sleepMillis);
 }
}

代码示例来源:origin: com.n3twork.druid/druid-common

private void poll()
{
 for (Map.Entry<String, ConfigHolder> entry : watchedConfigs.entrySet()) {
  try {
   if (entry.getValue().swapIfNew(dbConnector.lookup(configTable, "name", "payload", entry.getKey()))) {
    log.info("New value for key[%s] seen.", entry.getKey());
   }
  }
  catch (Exception e) {
   log.warn(e, "Exception when checking property[%s]", entry.getKey());
  }
 }
}

代码示例来源:origin: com.n3twork.druid/druid-server

private QueryableDruidServer addServer(DruidServer server)
{
 QueryableDruidServer retVal = new QueryableDruidServer(server, makeDirectClient(server));
 QueryableDruidServer exists = clients.put(server.getName(), retVal);
 if (exists != null) {
  log.warn("QueryRunner for server[%s] already existed!? Well it's getting replaced", server);
 }
 return retVal;
}

代码示例来源:origin: com.n3twork.druid/druid-server

@Override
public void put(NamedKey key, byte[] value)
{
 try {
  client.set(computeKeyHash(memcachedPrefix, key), expiration, serializeValue(key, value));
 } catch(IllegalStateException e) {
  // operation did not get queued in time (queue is full)
  errorCount.incrementAndGet();
  log.warn(e, "Unable to queue cache operation");
 }
}

代码示例来源:origin: com.n3twork.druid/druid-indexing-service

public void unannounceTask(String taskId)
{
 try {
  curatorFramework.delete().guaranteed().forPath(getTaskPathForId(taskId));
 }
 catch (Exception e) {
  log.warn(e, "Could not delete task path for task[%s]", taskId);
 }
}

代码示例来源:origin: metamx/java-util

@Test
public void testLogWithCrazyMessages()
{
 final String message = "this % might %d kill %*.s the %s parser";
 final Logger log = new Logger(LoggerTest.class);
 log.warn(message);
}

代码示例来源:origin: metamx/java-util

@Test
 public void testLegacyLogging()
 {
  final Logger log = new Logger(LoggerTest.class);
  final Throwable throwable = new Throwable();
  // These should show up in an IDE as deprecated, but shouldn't actually fail.
  log.error("foo", throwable);
  log.warn("foo", throwable);
 }
}

相关文章