org.webpieces.util.logging.Logger.warn()方法的使用及代码示例

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

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

Logger.warn介绍

[英]Log a message at the WARN level.
[中]以警告级别记录消息。

代码示例

代码示例来源:origin: org.webpieces/http-router

public void printRoutes(boolean isHttps, String tabSpaces) {
  //This is a pain but dynamically build up the html
  String routeHtml = build(tabSpaces);
  
  //print in warn so it's in red for anyone and to stderr IF they have debug enabled
  //it's kind of weird BUT great for tests
  if(!isHttps)
    log.warn("WARNING: The request is NOT https so perhaps your route is only accessible over https so modify your request" + routeHtml);
  else
    log.warn(routeHtml);
}

代码示例来源:origin: org.webpieces/http-router

private BiFunction<Object, Object, Void> createFunction(Class<? extends Object> beanClass, Field field) {
  String key = field.getName();
  String cap = key.substring(0, 1).toUpperCase() + key.substring(1);
  String methodName = "set"+cap;
  //What is slower....throwing exceptions or looping over methods to not through exception?....
  try {
    Method method = beanClass.getMethod(methodName, field.getType());
    return (bean, val) -> invokeMethod(method, bean, val);
  } catch (NoSuchMethodException e) {
    log.warn("performance penalty since method="+methodName+" does not exist on class="+beanClass.getName()+" using field instead to set data");
    return (bean, val) -> setField(field, bean, val);
  } catch (SecurityException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.webpieces/core-util

@Override
public void execute(Object key, Runnable r) {
  if(isFromThisPool.get() != null) {
    //if this threadpool is dumping into this threadpool, continue to drive it through so
    //the whole chain can gc faster(better to complete requests/responses all the way through than
    //parallelize too many
    r.run();
    return;
  }
  
  synchronized(this) {
    if(currentlyRunning.contains(key)) {
      cacheRunnable(key, new RunnableWithKey(key, r));
      return;
    } else {
      currentlyRunning.add(key);
    }
    
    if(counter >= 10000)
      log.warn("Session executor is falling behind on incoming data, possibly add back pressure", new RuntimeException());
  }
  executor.execute(new RunnableWithKey(key, r));
}

代码示例来源:origin: org.webpieces/core-util

@Override
public void execute(Object key, Runnable r) {
  synchronized(translate(key)) {
    if(currentlyRunning.containsKey(key)) {
      cacheRunnable(key, new RunnableWithKey(key, r));
      return;
    } else {
      currentlyRunning.put(key, Boolean.TRUE);
    }
    
    if(counter >= 10000)
      log.warn("Session executor is falling behind on incoming data, possibly add back pressure", new RuntimeException());
  }
  executor.execute(new RunnableWithKey(key, r));
}

代码示例来源:origin: org.webpieces/core-util

@SuppressWarnings("unchecked")
public <RESP> CompletableFuture<RESP> runRequest(Supplier<CompletableFuture<RESP>> processor) {
  long countId = counter.getAndIncrement();
  long time = System.currentTimeMillis();
  CompletableFuture<RESP> future = new CompletableFuture<RESP>();
  queue.add(new QueuedRequest<RESP>(future, processor, time));
  //take a peek at the first item in queue and see when it was queued
  QueuedRequest<RESP> item = (QueuedRequest<RESP>) queue.peek();
  if(item != null) {
    long timeQueued = item.getTimeQueued();
    long timeDelayed = time - timeQueued;
    if(timeDelayed > timeMsWarning)
      log.warn("id:"+logId+countId+" Your PermitQueue/Lock has the first item in the queue waiting "+timeDelayed+"ms so you may have deadlock or just a very contentious lock(you probably should look into this)");		
    if(backupSize() > queuedBackupWarnThreshold)
      log.warn("id:"+logId+countId+" Your lock is backing up with requests.  either too much contention or deadlock occurred(either way, you should fix this)");
  }
  
  processItemFromQueue();
  
  return future;
}

代码示例来源:origin: org.webpieces/http-templating

protected void put(HtmlTag tag) {
  HtmlTag htmlTag = tags.get(tag.getName());
  if(htmlTag != null)
    log.warn("You are overriding Tag="+tag.getName()+" from class="+htmlTag.getClass()+" to your class="+tag.getClass());
  else
    log.info("adding tag="+tag.getName());
  tags.put(tag.getName(), tag);
}

代码示例来源:origin: org.webpieces/core-util

public <RESP> CompletableFuture<RESP> lock(Function<Lock, CompletableFuture<RESP>> processor) {
  int id = counter.getAndIncrement();
  String key = logId+id;
  if(permitQueue.backupSize() > queuedBackupWarnThreshold)
    log.warn("id:"+key+" Your lock is backing up with requests.  either too much contention or deadlock occurred(either way, you should fix this)");
  
  Lock lock = new LockImpl(key);
  Supplier<CompletableFuture<RESP>> proxy = new Supplier<CompletableFuture<RESP>>() {
    public CompletableFuture<RESP> get() {
      log.info("key:"+key+" enter async sync block");
      CompletableFuture<RESP> fut = processor.apply(lock);
      return fut;
    }
  };
  
  log.info("key:"+key+" aboud to get lock or get queued");
  
  return permitQueue.runRequest(proxy);
}

代码示例来源:origin: org.webpieces/core-statemachine

private State fire(Object evt, StateMachineState smState) {
  try {
    //get the current state
    StateImpl state = nameToState.get(smState.getCurrentState().getName());
    state.fireEvent(smState, evt);
    return smState.getCurrentState();
  } catch(RuntimeException e) {
    //NOTE: Stack trace is not logged here.  That is the responsibility of the javasm client
    //so exceptions don't get logged multiple times.
    log.warn(this+"Exception occurred going out of state="+smState.getCurrentState()+", event="+evt);
    throw e;
  }
}

代码示例来源:origin: org.webpieces/hibernate-plugin

@Override
public <T> boolean isManaged(Class<T> paramTypeToCreate) {
  EntityManager entityManager = Em.get();
  try {
    ManagedType<T> managedType = entityManager.getMetamodel().managedType(paramTypeToCreate);
    EntityTypeImpl<T> entityType = (EntityTypeImpl<T>) managedType;
    if(!entityType.hasSingleIdAttribute()) {
      log.warn("You generally should be using beans with hibernate ids since this is a hibernate class");
      return false; //if no single id attribute, let the default creator create the bean
    }
    
  } catch(IllegalArgumentException e) {
    return false;
  }
  return true;
}

代码示例来源:origin: org.webpieces/plugin-hibernate

@Override
public <T> boolean isManaged(Class<T> paramTypeToCreate) {
  EntityManager entityManager = Em.get();
  try {
    ManagedType<T> managedType = entityManager.getMetamodel().managedType(paramTypeToCreate);
    EntityTypeImpl<T> entityType = (EntityTypeImpl<T>) managedType;
    if(!entityType.hasSingleIdAttribute()) {
      log.warn("You generally should be using beans with hibernate ids since this is a hibernate class");
      return false; //if no single id attribute, let the default creator create the bean
    }
    
  } catch(IllegalArgumentException e) {
    return false;
  }
  return true;
}

代码示例来源:origin: org.webpieces/core-channelmanager2

log.warn(channel+"Overloaded channel.  unregistering until YOU catch up you slowass(lol). num="+unackedByteCnt+" max="+channel.getMaxUnacked());
unregisterSelectableChannel(channel, SelectionKey.OP_READ);
  log.warn(channel+"BOOM. you caught back up, reregistering for reads now. unackedCnt="+unackedCnt+" readThreshold="+channel.getReadThreshold());
  channel.registerForReads();

代码示例来源:origin: org.webpieces/http-router

@Override
public final CompletableFuture<Void> incomingCompleteRequest(RouterRequest routerRequest, ResponseStreamer responseCb) {
  try {
    if(!started)
      throw new IllegalStateException("Either start was not called by client or start threw an exception that client ignored and must be fixed");;
    
    Session session = (Session) cookieTranslator.translateCookieToScope(routerRequest, new SessionImpl(translator));
    FlashSub flash = (FlashSub) cookieTranslator.translateCookieToScope(routerRequest, new FlashImpl(translator));
    Validation validation = (Validation) cookieTranslator.translateCookieToScope(routerRequest, new ValidationImpl(translator));
    RequestContext requestCtx = new RequestContext(validation, flash, session, routerRequest);
    
    return processRequest(requestCtx, responseCb);
    
  } catch(BadCookieException e) {
    throw e;
  } catch (Throwable e) {
    log.warn("uncaught exception", e);
    return responseCb.failureRenderingInternalServerErrorPage(e);
  }
}

代码示例来源:origin: org.webpieces/core-statemachine

/**
 * @param smState
 * @param evt
 */
public void fireEvent(StateMachineState smState, Object evt)
{
  TransitionImpl transition = evtToTransition.get(evt);
  if(transition == null) {
    log.debug(() -> smState+"No Transition: "+getName()+" -> <no transition found>, event="+evt);
    if(noTransitionListener != null)
      noTransitionListener.noTransitionFromEvent(smState.getCurrentState(), evt);
    return;
  }
  State nextState = transition.getEndState();
  if(log.isDebugEnabled())
    log.debug(() -> smState+"Transition: "+getName()+" -> "+nextState+", event="+evt);
  try {
    smState.setCurrentState(nextState);
  } catch(RuntimeException e) {
    log.warn(smState+"Transition FAILED: "+getName()+" -> "+nextState+", event="+evt);
    throw e;
  }
}

相关文章

微信公众号

最新文章

更多