java.util.logging.Level#INFO源码实例Demo

下面列出了java.util.logging.Level#INFO 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AndrOBD   文件: MainActivity.java
/**
 * Set logging levels from shared preferences
 */
private void setLogLevels()
{
	// get level from preferences
	Level level;
       try
       {
           level = Level.parse(prefs.getString(LOG_MASTER, "INFO"));
       }
       catch(Exception e)
       {
           level = Level.INFO;
       }

       // set logger main level
	MainActivity.rootLogger.setLevel(level);
}
 
源代码2 项目: netbeans   文件: InstallerReadPageTest.java
@RandomlyFails // NB-Core-Build #7964
public void testSendLogWithException() throws Exception {
    Logger uiLogger = Logger.getLogger(Installer.UI_LOGGER_NAME);
    LogRecord log1 = new LogRecord(Level.SEVERE, "TESTING MESSAGE");
    LogRecord log2 = new LogRecord(Level.SEVERE, "TESTING MESSAGE");
    LogRecord log3 = new LogRecord(Level.SEVERE, "NO EXCEPTION LOG");
    LogRecord log4 = new LogRecord(Level.INFO, "INFO");
    Throwable t1 = new NullPointerException("TESTING THROWABLE");
    Throwable t2 = new UnknownError("TESTING ERROR");
    log1.setThrown(t1);
    log2.setThrown(t2);
    log4.setThrown(t2);
    Installer installer = Installer.findObject(Installer.class, true);
    assertNotNull(installer);
    installer.restored();
    uiLogger.log(log1);
    uiLogger.log(log2);
    uiLogger.log(log3);
    UIHandler.waitFlushed();
    if (Installer.getThrown() == null) {
        fail("Exception should be found in the log");
    }
    
    doEncodingTest("UTF-8", "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'></meta>");
}
 
源代码3 项目: openjdk-8-source   文件: Logging.java
/**
 * Initialization function that is called to instantiate the logging system. It takes
 * logger names (keys) and logging labels respectively
 *
 * @param map a map where the key is a logger name and the value a logging level
 * @throws IllegalArgumentException if level or names cannot be parsed
 */
public static void initialize(final Map<String, String> map) throws IllegalArgumentException {
    try {
        for (final Entry<String, String> entry : map.entrySet()) {
            Level level;

            final String key   = entry.getKey();
            final String value = entry.getValue();
            if ("".equals(value)) {
                level = Level.INFO;
            } else {
                level = Level.parse(value.toUpperCase(Locale.ENGLISH));
            }

            final String name = Logging.lastPart(key);
            final Logger logger = instantiateLogger(name, level);

            Logging.loggers.put(name, logger);
        }
    } catch (final IllegalArgumentException | SecurityException e) {
        throw e;
    }
}
 
源代码4 项目: netbeans   文件: UINodeTest.java
public void testIconOfTheNode() throws Exception {
    LogRecord r = new LogRecord(Level.INFO, "icon_msg");
    r.setResourceBundleName("org.netbeans.modules.uihandler.TestBundle");
    r.setResourceBundle(ResourceBundle.getBundle("org.netbeans.modules.uihandler.TestBundle"));
    r.setParameters(new Object[] { new Integer(1), "Ahoj" });
    
    Node n = UINode.create(r);
    assertEquals("Name is taken from the message", "icon_msg", n.getName());
    
    if (!n.getDisplayName().matches(".*Ahoj.*")) {
        fail("wrong display name, shall contain Ahoj: " + n.getDisplayName());
    }
    
    Image img = n.getIcon(BeanInfo.ICON_COLOR_32x32);
    assertNotNull("Some icon", img);
    IconInfo imgReal = new IconInfo(img);
    IconInfo template = new IconInfo(getClass().getResource("testicon.png"));
    assertEquals("Icon from ICON_BASE used", template, imgReal);
    
    assertSerializedWell(n);
}
 
源代码5 项目: buck   文件: ConsoleHandlerTest.java
@Test
public void previouslyRegisteredOutputStreamCanBeOverridden() throws IOException {
  FakeOutputStream outputStream1 = new FakeOutputStream();
  FakeOutputStream outputStream2 = new FakeOutputStream();
  FakeOutputStream outputStream3 = new FakeOutputStream();
  ConsoleHandler handler =
      new ConsoleHandler(
          ConsoleHandler.utf8OutputStreamWriter(outputStream1),
          new MessageOnlyFormatter(),
          Level.INFO,
          state);

  threadIdToCommandId.put(49152L, "commandIdForOutputStream2");
  registerOutputStream("commandIdForOutputStream2", outputStream2);

  publishAndFlush(handler, newLogRecordWithThreadId(Level.INFO, "Stream 2", 49152));
  assertThat(outputStream1.toString("UTF-8"), equalTo(""));
  assertThat(outputStream2.toString("UTF-8"), equalTo("Stream 2"));

  registerOutputStream("commandIdForOutputStream2", outputStream3);

  publishAndFlush(handler, newLogRecordWithThreadId(Level.INFO, "Stream 3", 49152));
  assertThat(outputStream1.toString("UTF-8"), equalTo(""));
  assertThat(outputStream2.toString("UTF-8"), equalTo("Stream 2"));
  assertThat(outputStream3.toString("UTF-8"), equalTo("Stream 3"));
}
 
源代码6 项目: bazel   文件: InvocationPolicyEnforcerTestBase.java
static InvocationPolicyEnforcer createOptionsPolicyEnforcer(
    InvocationPolicy.Builder invocationPolicyBuilder) throws Exception {
  InvocationPolicy policyProto = invocationPolicyBuilder.build();

  // An OptionsPolicyEnforcer could be constructed in the test directly from the InvocationPolicy
  // proto, however Blaze will actually take the policy as another flag with a Base64 encoded
  // binary proto and parse that, so exercise that code path in the test.

  ByteArrayOutputStream out = new ByteArrayOutputStream();
  policyProto.writeTo(out);
  String policyBase64 = BaseEncoding.base64().encode(out.toByteArray());

  OptionsParser startupOptionsParser =
      OptionsParser.builder().optionsClasses(BlazeServerStartupOptions.class).build();
  String policyOption = "--invocation_policy=" + policyBase64;
  startupOptionsParser.parse(policyOption);

  return new InvocationPolicyEnforcer(
      InvocationPolicyParser.parsePolicy(
          startupOptionsParser.getOptions(BlazeServerStartupOptions.class).invocationPolicy),
      Level.INFO);
}
 
源代码7 项目: yajsync   文件: Util.java
/**
 * NOTE: we don't use Level.CONFIG at all
 */
public static Level getLogLevelForNumber(int level)
{
    Level[] logLevels = { Level.SEVERE, Level.WARNING, Level.INFO,
                          Level.FINE, Level.FINER, Level.FINEST };
    return logLevels[Math.min(logLevels.length - 1, level)];
}
 
源代码8 项目: vicinity-gateway-api   文件: App.java
/**
 * Translates the string value of logging level configuration parameter to
 * {@link java.util.logging.Level Level} object, that can be fed to
 * {@link java.util.logging.logger Logger}. If the stringValue is null, it will
 * return the default logging level set by {@link #CONFIG_DEF_LOGGINGLEVEL
 * CONFIG_DEF_LOGGINGLEVEL} constant. If the string contains other unexpected
 * value (worst case) returns {@link java.util.logging.level#INFO INFO}.
 * 
 * @param stringValue String value of the configuration parameter.
 * @return String translated into {@link java.util.logging.level Level} object.
 */
private static Level translateLoggingLevel(String stringValue) {

	if (stringValue == null) {
		stringValue = CONFIG_DEF_LOGGINGLEVEL;
	}

	switch (stringValue) {

		case "OFF":
			return Level.OFF;

		case "SEVERE":
			return Level.SEVERE;

		case "WARNING":
			return Level.WARNING;

		case "INFO":
			return Level.INFO;

		case "CONFIG":
			return Level.CONFIG;

		case "FINE":
			return Level.FINE;

		case "FINER":
			return Level.FINER;

		case "FINEST":
			return Level.FINEST;

		default:
			return Level.INFO;
	}
}
 
源代码9 项目: beam   文件: LogRecordMatcherTest.java
@Test
public void testMessageMismatch() {
  LogRecord record = new LogRecord(Level.INFO, "foo");
  try {
    assertThat(record, LogRecordMatcher.hasLog("bar"));
  } catch (AssertionError e) {
    return;
  }

  fail("Expected exception not thrown");
}
 
源代码10 项目: netbeans   文件: Util.java
public static void logUsage(Class srcClass, String message, Object ...params) {
    Parameters.notNull("message", message); // NOI18N

    LogRecord logRecord = new LogRecord(Level.INFO, message);
    logRecord.setLoggerName(USG_LOGGER.getName());
    logRecord.setResourceBundle(NbBundle.getBundle(srcClass));
    logRecord.setResourceBundleName(srcClass.getPackage().getName() + ".Bundle"); // NOI18N
    if (params != null) {
        logRecord.setParameters(params);
    }
    USG_LOGGER.log(logRecord);
}
 
源代码11 项目: netbeans   文件: GestureSubmitter.java
private static void logUsage(String startType, List<Object> params) {
    LogRecord record = new LogRecord(Level.INFO, "USG_PROFILER_" + startType); // NOI18N
    record.setResourceBundle(NbBundle.getBundle(GestureSubmitter.class));
    record.setResourceBundleName(GestureSubmitter.class.getPackage().getName() + ".Bundle"); // NOI18N
    record.setLoggerName(USG_LOGGER.getName());
    record.setParameters(params.toArray(new Object[0]));

    USG_LOGGER.log(record);
}
 
源代码12 项目: openwebbeans-meecrowave   文件: Log4j2Logger.java
private Level fromL4J(final org.apache.logging.log4j.Level l) {
    Level l2 = null;
    switch (l.getStandardLevel()) {
        case ALL:
            l2 = Level.ALL;
            break;
        case FATAL:
            l2 = Level.SEVERE;
            break;
        case ERROR:
            l2 = Level.SEVERE;
            break;
        case WARN:
            l2 = Level.WARNING;
            break;
        case INFO:
            l2 = Level.INFO;
            break;
        case DEBUG:
            l2 = Level.FINE;
            break;
        case OFF:
            l2 = Level.OFF;
            break;
        case TRACE:
            l2 = Level.FINEST;
            break;
        default:
            l2 = Level.FINE;
    }
    return l2;
}
 
源代码13 项目: buck   文件: ConsoleHandlerTest.java
@Test
public void levelOverrideCanBeRemoved() throws IOException {
  FakeOutputStream outputStream1 = new FakeOutputStream();
  FakeOutputStream outputStream2 = new FakeOutputStream();
  FakeOutputStream outputStream3 = new FakeOutputStream();
  ConsoleHandler handler =
      new ConsoleHandler(
          ConsoleHandler.utf8OutputStreamWriter(outputStream1),
          new MessageOnlyFormatter(),
          Level.INFO,
          state);

  threadIdToCommandId.put(49152L, "commandIdForOutputStream2");
  threadIdToCommandId.put(64738L, "commandIdForOutputStream3");
  registerOutputStream("commandIdForOutputStream2", outputStream2);
  registerOutputStream("commandIdForOutputStream3", outputStream3);

  commandIdToLevel.put("commandIdForOutputStream3", Level.FINE);

  publishAndFlush(handler, newLogRecordWithThreadId(Level.FINE, "Stream 3", 64738));
  assertThat(outputStream1.toString("UTF-8"), equalTo(""));
  assertThat(outputStream2.toString("UTF-8"), equalTo(""));
  assertThat(outputStream3.toString("UTF-8"), equalTo("Stream 3"));

  commandIdToLevel.remove("commandIdForOutputStream3");
  publishAndFlush(handler, newLogRecordWithThreadId(Level.FINE, "Shh...", 64738));
  assertThat(outputStream1.toString("UTF-8"), equalTo(""));
  assertThat(outputStream2.toString("UTF-8"), equalTo(""));
  assertThat(outputStream3.toString("UTF-8"), equalTo("Stream 3"));
}
 
源代码14 项目: git-client-plugin   文件: LogHandlerTest.java
private void publishMessage(String message) {
    LogRecord lr = new LogRecord(Level.INFO, message);
    handler.publish(lr);
    List<String> messages = handler.getMessages();
    assertEquals(message, messages.get(0));
    assertEquals("Wrong size list of messages", 1, messages.size());
}
 
源代码15 项目: reactor-core   文件: SignalLogger.java
@Override
@Nullable
public Runnable onCancelCall() {
	if ((options & CANCEL) == CANCEL && (level != Level.INFO || log.isInfoEnabled())) {
		return () -> log(SignalType.CANCEL, "");
	}
	return null;
}
 
源代码16 项目: L2jBrasil   文件: L2ItemInstance.java
/**
 * Sets the ownerID of the item
 * @param process : String Identifier of process triggering this action
 * @param owner_id : int designating the ID of the owner
 * @param creator : L2PcInstance Player requesting the item creation
 * @param reference : L2Object Object referencing current action like NPC selling item or previous item in transformation
 */
public void setOwnerId(String process, int owner_id, L2PcInstance creator, L2Object reference)
{
	setOwnerId(owner_id);
	if (Config.LOG_ITEMS)
	{
		LogRecord record = new LogRecord(Level.INFO, "CHANGE:" + process);
		record.setLoggerName("item");
		record.setParameters(new Object[]{this, creator, reference});
		_logItems.log(record);
	}
}
 
protected String getThreadName(LogRecord record) {
    //try to get the thread's name
    //only possible if we are the thread (unless do something messy like cache or access private fields)
    //fortunately we typically are the thread
    LogRecord lr = new LogRecord(Level.INFO, "");
    if (lr.getThreadID()==record.getThreadID())
        return Thread.currentThread().getName() + " ("+record.getThreadID()+")";
    //otherwise just say the number
    return "thread ("+record.getThreadID()+")";
}
 
源代码18 项目: netbeans   文件: NbModuleTestingTest.java
@Override
protected Level logLevel() {
    return Level.INFO;
}
 
源代码19 项目: Knowage-Server   文件: BirtEngine.java
/**
 * Gets the birt engine.
 *
 * @param request
 *            the request
 * @param sc
 *            the sc
 *
 * @return the birt engine
 */
public static synchronized IReportEngine getBirtEngine(HttpServletRequest request, ServletContext sc) {
	logger.debug("IN");
	// birtEngine = null;
	if (birtEngine == null) {
		EngineConfig config = new EngineConfig();
		if (configProps != null && !configProps.isEmpty()) {
			String logLevel = configProps.getProperty("logLevel");
			Level level = Level.OFF;
			if ("SEVERE".equalsIgnoreCase(logLevel)) {
				level = Level.SEVERE;
			} else if ("WARNING".equalsIgnoreCase(logLevel)) {
				level = Level.WARNING;
			} else if ("INFO".equalsIgnoreCase(logLevel)) {
				level = Level.INFO;
			} else if ("CONFIG".equalsIgnoreCase(logLevel)) {
				level = Level.CONFIG;
			} else if ("FINE".equalsIgnoreCase(logLevel)) {
				level = Level.FINE;
			} else if ("FINER".equalsIgnoreCase(logLevel)) {
				level = Level.FINER;
			} else if ("FINEST".equalsIgnoreCase(logLevel)) {
				level = Level.FINEST;
			} else if ("ALL".equalsIgnoreCase(logLevel)) {
				level = Level.ALL;
			} else if ("OFF".equalsIgnoreCase(logLevel)) {
				level = Level.OFF;
			}

			String logDir = configProps.getProperty("logDirectory");
			logDir = Utils.resolveSystemProperties(logDir);
			logger.debug("Birt LOG Dir:" + logDir);
			logger.debug("Log config: logDirectory = [" + logDir + "]; level = [" + level + "]");
			config.setLogConfig(logDir, level);
		}

		/*
		 * DefaultResourceLocator drl=new DefaultResourceLocator(); drl.findResource(birtEngine.openReportDesign(arg0), "messages_it_IT.properties",
		 * DefaultResourceLocator.MESSAGE_FILE);
		 */
		// Commented for Birt 3.7 Upgrade see: http://wiki.eclipse.org/Birt_3.7_Migration_Guide#BIRT_3.7_API_Changes
		// config.setEngineHome("");
		IPlatformContext context = new PlatformServletContext(sc);
		config.setPlatformContext(context);
		config.setTempDir(System.getProperty("java.io.tmpdir") + "/birt/");

		// ParameterAccessor.initParameters(sc);
		// config.setResourcePath(ParameterAccessor.getResourceFolder(request));
		// Prepare ScriptLib location
		String scriptLibDir = ParameterAccessor.scriptLibDir;
		ArrayList jarFileList = new ArrayList();
		if (scriptLibDir != null) {
			File dir = new File(scriptLibDir);
			getAllJarFiles(dir, jarFileList);
		}
		String scriptlibClassPath = ""; //$NON-NLS-1$
		for (int i = 0; i < jarFileList.size(); i++)
			scriptlibClassPath += EngineConstants.PROPERTYSEPARATOR + ((File) jarFileList.get(i)).getAbsolutePath();
		if (scriptlibClassPath.startsWith(EngineConstants.PROPERTYSEPARATOR))
			scriptlibClassPath = scriptlibClassPath.substring(EngineConstants.PROPERTYSEPARATOR.length());
		config.setProperty(EngineConstants.WEBAPP_CLASSPATH_KEY, scriptlibClassPath);

		try {
			Platform.startup(config);
			logger.debug("Birt Platform started");
		} catch (BirtException e) {
			logger.error("Error during Birt Platform start-up", e);
		}

		IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
		birtEngine = factory.createReportEngine(config);
		logger.debug("Report engine created");

	}
	return birtEngine;
}
 
源代码20 项目: netbeans   文件: AttrSetTest.java
@Override
protected Level logLevel() {
    return Level.INFO;
}