Java Code Examples for java.util.logging.Level#INFO

The following examples show how to use java.util.logging.Level#INFO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From AndrOBD with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: InstallerReadPageTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@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>");
}
 
Example 3
Source File: Logging.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 4
Source File: InvocationPolicyEnforcerTestBase.java    From bazel with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 5
Source File: ConsoleHandlerTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@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"));
}
 
Example 6
Source File: UINodeTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 7
Source File: GestureSubmitter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 8
Source File: SimpleOneLineLogFormatter.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
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()+")";
}
 
Example 9
Source File: L2ItemInstance.java    From L2jBrasil with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 10
Source File: SignalLogger.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public Runnable onCancelCall() {
	if ((options & CANCEL) == CANCEL && (level != Level.INFO || log.isInfoEnabled())) {
		return () -> log(SignalType.CANCEL, "");
	}
	return null;
}
 
Example 11
Source File: LogHandlerTest.java    From git-client-plugin with MIT License 5 votes vote down vote up
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());
}
 
Example 12
Source File: ConsoleHandlerTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@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"));
}
 
Example 13
Source File: Log4j2Logger.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: Util.java    From yajsync with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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)];
}
 
Example 15
Source File: Util.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 16
Source File: LogRecordMatcherTest.java    From beam with Apache License 2.0 5 votes vote down vote up
@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");
}
 
Example 17
Source File: App.java    From vicinity-gateway-api with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
	}
}
 
Example 18
Source File: AttrSetTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Level logLevel() {
    return Level.INFO;
}
 
Example 19
Source File: BirtEngine.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 20
Source File: NbModuleTestingTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected Level logLevel() {
    return Level.INFO;
}