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

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

本文整理了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

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

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

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

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

  1. @Override
  2. public void execute(Object key, Runnable r) {
  3. if(isFromThisPool.get() != null) {
  4. //if this threadpool is dumping into this threadpool, continue to drive it through so
  5. //the whole chain can gc faster(better to complete requests/responses all the way through than
  6. //parallelize too many
  7. r.run();
  8. return;
  9. }
  10. synchronized(this) {
  11. if(currentlyRunning.contains(key)) {
  12. cacheRunnable(key, new RunnableWithKey(key, r));
  13. return;
  14. } else {
  15. currentlyRunning.add(key);
  16. }
  17. if(counter >= 10000)
  18. log.warn("Session executor is falling behind on incoming data, possibly add back pressure", new RuntimeException());
  19. }
  20. executor.execute(new RunnableWithKey(key, r));
  21. }

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

  1. @Override
  2. public void execute(Object key, Runnable r) {
  3. synchronized(translate(key)) {
  4. if(currentlyRunning.containsKey(key)) {
  5. cacheRunnable(key, new RunnableWithKey(key, r));
  6. return;
  7. } else {
  8. currentlyRunning.put(key, Boolean.TRUE);
  9. }
  10. if(counter >= 10000)
  11. log.warn("Session executor is falling behind on incoming data, possibly add back pressure", new RuntimeException());
  12. }
  13. executor.execute(new RunnableWithKey(key, r));
  14. }

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

  1. @SuppressWarnings("unchecked")
  2. public <RESP> CompletableFuture<RESP> runRequest(Supplier<CompletableFuture<RESP>> processor) {
  3. long countId = counter.getAndIncrement();
  4. long time = System.currentTimeMillis();
  5. CompletableFuture<RESP> future = new CompletableFuture<RESP>();
  6. queue.add(new QueuedRequest<RESP>(future, processor, time));
  7. //take a peek at the first item in queue and see when it was queued
  8. QueuedRequest<RESP> item = (QueuedRequest<RESP>) queue.peek();
  9. if(item != null) {
  10. long timeQueued = item.getTimeQueued();
  11. long timeDelayed = time - timeQueued;
  12. if(timeDelayed > timeMsWarning)
  13. 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)");
  14. if(backupSize() > queuedBackupWarnThreshold)
  15. 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)");
  16. }
  17. processItemFromQueue();
  18. return future;
  19. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * @param smState
  3. * @param evt
  4. */
  5. public void fireEvent(StateMachineState smState, Object evt)
  6. {
  7. TransitionImpl transition = evtToTransition.get(evt);
  8. if(transition == null) {
  9. log.debug(() -> smState+"No Transition: "+getName()+" -> <no transition found>, event="+evt);
  10. if(noTransitionListener != null)
  11. noTransitionListener.noTransitionFromEvent(smState.getCurrentState(), evt);
  12. return;
  13. }
  14. State nextState = transition.getEndState();
  15. if(log.isDebugEnabled())
  16. log.debug(() -> smState+"Transition: "+getName()+" -> "+nextState+", event="+evt);
  17. try {
  18. smState.setCurrentState(nextState);
  19. } catch(RuntimeException e) {
  20. log.warn(smState+"Transition FAILED: "+getName()+" -> "+nextState+", event="+evt);
  21. throw e;
  22. }
  23. }

相关文章