Java 类ch.qos.logback.core.status.WarnStatus 实例源码

项目:konker-platform    文件:KonkerContextInitializer.java   
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
    Set urlSet = null;
    StatusManager sm = this.loggerContext.getStatusManager();

    try {
        urlSet = Loader.getResourceOccurrenceCount(resourceName, classLoader);
    } catch (IOException var7) {
        sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]", this.loggerContext, var7));
    }

    if (urlSet != null && urlSet.size() > 1) {
        sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.", this.loggerContext));
        Iterator i$ = urlSet.iterator();

        while (i$.hasNext()) {
            URL url = (URL) i$.next();
            sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]", this.loggerContext));
        }
    }

}
项目:bartleby    文件:ContextJNDISelector.java   
private URL findConfigFileURL(Context ctx, LoggerContext loggerContext) {
  StatusManager sm = loggerContext.getStatusManager();

  String jndiEntryForConfigResource = JNDIUtil.lookup(ctx,
          JNDI_CONFIGURATION_RESOURCE);
  // Do we have a dedicated configuration file?
  if (jndiEntryForConfigResource != null) {
    sm.add(new InfoStatus("Searching for [" + jndiEntryForConfigResource
            + "]", this));
    URL url = urlByResourceName(sm, jndiEntryForConfigResource);
    if (url == null) {
      String msg = "The jndi resource [" + jndiEntryForConfigResource
              + "] for context [" + loggerContext.getName()
              + "] does not lead to a valid file";
      sm.add(new WarnStatus(msg, this));
    }
    return url;
  } else {
    String resourceByConvention = conventionalConfigFileName(loggerContext
            .getName());
    return urlByResourceName(sm, resourceByConvention);
  }
}
项目:bartleby    文件:ContextInitializer.java   
private void multiplicityWarning(String resourceName, ClassLoader classLoader) {
  Set<URL> urlSet = null;
  StatusManager sm = loggerContext.getStatusManager();
  try {
    urlSet = Loader.getResourceOccurrenceCount(resourceName, classLoader);
  } catch (IOException e) {
    sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]",
            loggerContext, e));
  }
  if (urlSet != null && urlSet.size() > 1) {
    sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.",
            loggerContext));
    for (URL url : urlSet) {
      sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]",
              loggerContext));
    }
  }
}
项目:goodees    文件:CatalinaValve.java   
@Override
public void start() throws LifecycleException {
    super.start();
    ctx.start();
    if (filename == null) {
        filename = OptionHelper.getSystemProperty("logbackAccess.configurationFile");
        if (filename == null) {
            filename = DEFAULT_CONFIG_FILE;
        }
        ctx.getStatusManager().add(new InfoStatus("filename property not set. Assuming [" + filename + "]", this));
    }
    // TODO: Support classpath config
    File configFile = new File(filename);
    if (configFile.exists()) {
        try {
            JoranConfigurator jc = new JoranConfigurator();
            jc.setContext(ctx);
            jc.doConfigure(filename);
        } catch (JoranException e) {
            // TODO can we do better than printing a stack trace on syserr?
            e.printStackTrace();
        }
    } else {
        ctx.getStatusManager().add(new WarnStatus("[" + filename + "] does not exist", this));
    }

    if (!quiet) {
        StatusPrinter.print(ctx.getStatusManager());
    }

}
项目:minijax    文件:CloudWatchAppender.java   
@Override
public synchronized void start() {
    if (isStarted()) {
        return;
    }

    if (layout == null) {
        layout = new EchoLayout<>();
        addStatus(new WarnStatus("No layout, default to " + layout, this));
    }
    if (logGroupName == null) {
        logGroupName = getClass().getSimpleName();
        addStatus(new WarnStatus("No logGroupName, default to " + logGroupName, this));
    }
    if (logStreamName == null) {
        logStreamName = new SimpleDateFormat("yyyyMMdd'T'HHmmss").format(new Date());
        addStatus(new WarnStatus("No logGroupName, default to " + logStreamName, this));
    }
    try {
        if (awsLogs == null) {
            awsLogs = AWSLogsClientBuilder.defaultClient();
        }
        createLogGroup();
        createLogStream();
    } catch (final AmazonClientException e) {
        awsLogs = null;
        addStatus(new ErrorStatus(e.getMessage(), this, e));
    }

    // Start a new daemon time thread to periodically upload events
    // Because this is a deamon thread, it will not block shutdown
    new DaemonTimerThread().start();

    // Add a shutdown hook to catch any final events at shutdown
    Runtime.getRuntime().addShutdownHook(new ShutdownHook());

    layout.start();
    super.start();
}
项目:bartleby    文件:AppenderBase.java   
public synchronized void doAppend(E eventObject) {
  // WARNING: The guard check MUST be the first statement in the
  // doAppend() method.

  // prevent re-entry.
  if (guard) {
    return;
  }

  try {
    guard = true;

    if (!this.started) {
      if (statusRepeatCount++ < ALLOWED_REPEATS) {
        addStatus(new WarnStatus(
            "Attempted to append to non started appender [" + name + "].",
            this));
      }
      return;
    }

    if (getFilterChainDecision(eventObject) == FilterReply.DENY) {
      return;
    }

    // ok, we now invoke derived class' implementation of append
    this.append(eventObject);

  } catch (Exception e) {
    if (exceptionCount++ < ALLOWED_REPEATS) {
      addError("Appender [" + name + "] failed to append.", e);
    }
  } finally {
    guard = false;
  }
}
项目:bartleby    文件:ConsoleAppender.java   
private void targetWarn(String val) {
  Status status = new WarnStatus("[" + val + "] should be one of "
          + Arrays.toString(ConsoleTarget.values()), this);
  status.add(new WarnStatus(
          "Using previously set target, System.out by default.", this));
  addStatus(status);
}
项目:bartleby    文件:UnsynchronizedAppenderBase.java   
public void doAppend(E eventObject) {
  // WARNING: The guard check MUST be the first statement in the
  // doAppend() method.

  // prevent re-entry.
  if (Boolean.TRUE.equals(guard.get())) {
    return;
  }

  try {
    guard.set(Boolean.TRUE);

    if (!this.started) {
      if (statusRepeatCount++ < ALLOWED_REPEATS) {
        addStatus(new WarnStatus(
            "Attempted to append to non started appender [" + name + "].",
            this));
      }
      return;
    }

    if (getFilterChainDecision(eventObject) == FilterReply.DENY) {
      return;
    }

    // ok, we now invoke derived class' implementation of append
    this.append(eventObject);

  } catch (Exception e) {
    if (exceptionCount++ < ALLOWED_REPEATS) {
      addError("Appender [" + name + "] failed to append.", e);
    }
  } finally {
    guard.set(Boolean.FALSE);
  }
}
项目:bartleby    文件:StatusPrinterTest.java   
@Test
public void testNested() {
  Status s0 = new ErrorStatus("test0", this);
  Status s1 = new InfoStatus("test1", this);
  Status s11 = new InfoStatus("test11", this);
  Status s12 = new InfoStatus("test12", this);
  s1.add(s11);
  s1.add(s12);

  Status s2 = new InfoStatus("test2", this);
  Status s21 = new InfoStatus("test21", this);
  Status s211 = new WarnStatus("test211", this);

  Status s22 = new InfoStatus("test22", this);
  s2.add(s21);
  s2.add(s22);
  s21.add(s211);


  Context context = new ContextBase();
  context.getStatusManager().add(s0);
  context.getStatusManager().add(s1);
  context.getStatusManager().add(s2);

  StatusPrinter.print(context);
  String result = outputStream.toString();
  assertTrue(result.contains("+ INFO in "+this.getClass().getName()));
  assertTrue(result.contains("+ WARN in "+this.getClass().getName()));
  assertTrue(result.contains("    |-WARN in "+this.getClass().getName()));
}
项目:bartleby    文件:StatusPrinterTest.java   
@Test
public void testWithException() {
  Status s0 = new ErrorStatus("test0", this);
  Status s1 = new InfoStatus("test1", this, new Exception("testEx"));
  Status s11 = new InfoStatus("test11", this);
  Status s12 = new InfoStatus("test12", this);
  s1.add(s11);
  s1.add(s12);

  Status s2 = new InfoStatus("test2", this);
  Status s21 = new InfoStatus("test21", this);
  Status s211 = new WarnStatus("test211", this);

  Status s22 = new InfoStatus("test22", this);
  s2.add(s21);
  s2.add(s22);
  s21.add(s211);

  Context context = new ContextBase();
  context.getStatusManager().add(s0);
  context.getStatusManager().add(s1);
  context.getStatusManager().add(s2);
  StatusPrinter.print(context);  
  String result = outputStream.toString();
  assertTrue(result.contains("|-ERROR in "+this.getClass().getName()));
  assertTrue(result.contains("+ INFO in "+this.getClass().getName()));
  assertTrue(result.contains("ch.qos.logback.core.util.StatusPrinterTest.testWithException"));
}
项目:bartleby    文件:LoggerContext.java   
final void noAppenderDefinedWarning(final Logger logger) {
  if (noAppenderWarning++ == 0) {
    getStatusManager().add(
            new WarnStatus("No appenders present in context [" + getName()
                    + "] for logger [" + logger.getName() + "].", logger));
  }
}
项目:scylla-tools-java    文件:ConsoleAppender.java   
public void setTarget(String target)
{
    if(!(target.equals("System.out") || target.equals("System.err")))
    {
        Status status = new WarnStatus("[" + target + "] should be one of System.out or System.err", this);
        status.add(new WarnStatus("Using default target System.out", this));
        addStatus(status);
        return;
    }
    this.target = target;
}
项目:konker-platform    文件:KonkerLoggerContext.java   
final void noAppenderDefinedWarning(KonkerLogger logger) {
    if(this.noAppenderWarning++ == 0) {
        this.getStatusManager().add(new WarnStatus("No appenders present in context [" + this.getName() + "] for logger [" + logger.getName() + "].", logger));
    }

}
项目:bartleby    文件:ContextAwareImpl.java   
public void addWarn(String msg) {
  addStatus(new WarnStatus(msg, getOrigin()));
}
项目:bartleby    文件:ContextAwareImpl.java   
public void addWarn(String msg, Throwable ex) {
  addStatus(new WarnStatus(msg, getOrigin(), ex));
}
项目:bartleby    文件:ContextAwareBase.java   
public void addWarn(String msg) {
  addStatus(new WarnStatus(msg, getDeclaredOrigin()));
}
项目:bartleby    文件:ContextAwareBase.java   
public void addWarn(String msg, Throwable ex) {
  addStatus(new WarnStatus(msg, getDeclaredOrigin(), ex));
}
项目:bartleby    文件:ConfigurationWatchListUtil.java   
static void addWarn(Context context, String msg) {
  addStatus(context, new WarnStatus(msg, origin));
}
项目:bartleby    文件:LogbackValve.java   
@Override
public void startInternal() throws LifecycleException {
  executorService = ExecutorServiceUtil.newExecutorService();
  if (filename == null) {
    String tomcatBaseProperty = OptionHelper
        .getSystemProperty("catalina.base");

    filename = tomcatBaseProperty + File.separatorChar + DEFAULT_CONFIG_FILE;

    File baseConfigFile = new File(filename);
    if (!baseConfigFile.exists()) {

      String tomcatHomeProperty = OptionHelper
          .getSystemProperty("catalina.home");

      filename = tomcatHomeProperty + File.separatorChar
          + DEFAULT_CONFIG_FILE;
    }

    getStatusManager().add(
        new InfoStatus("filename property not set. Assuming [" + filename
            + "]", this));
  }
  File configFile = new File(filename);

  if (configFile.exists()) {
    try {
      JoranConfigurator jc = new JoranConfigurator();
      jc.setContext(this);
      jc.doConfigure(filename);
    } catch (JoranException e) {
      // TODO can we do better than printing a stack trace on syserr?
      e.printStackTrace();
    }
  } else {
    getStatusManager().add(
        new WarnStatus("[" + filename + "] does not exist", this));
  }

  if (!quiet) {
    StatusPrinter.print(getStatusManager());
  }

  started = true;
  setState(LifecycleState.STARTING);
}
项目:greenpepper    文件:DefaultLogbackConfigurator.java   
/** {@inheritDoc} */
@Override
public void addWarn(String msg) {
    context.getStatusManager().add(new WarnStatus(msg, context));
}
项目:greenpepper    文件:DefaultLogbackConfigurator.java   
/** {@inheritDoc} */
@Override
public void addWarn(String msg, Throwable ex) {
    context.getStatusManager().add(new WarnStatus(msg, context, ex));
}