Java Code Examples for java.util.logging.Level#getName()

The following examples show how to use java.util.logging.Level#getName() . 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: LogLevelMapper.java    From product-microgateway with Apache License 2.0 6 votes vote down vote up
public static String getCLILogLevel(Level level) {
    switch (level.getName()) {
    case "SEVERE":
        return "ERROR";
    case "WARNING":
        return "WARN";
    case "INFO":
        return "INFO";
    case "FINE":
        return "DEBUG";
    case "FINER":
        return "DEBUG";
    case "FINEST":
        return "TRACE";
    default:
        return "<UNDEFINED>";
    }
}
 
Example 2
Source File: JulInfo.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public String getLevel() {
  if(logger==null) {
    return null;
  }
  Level level = logger.getLevel();
  if (level != null) {
    return level.getName();
  }
  for (Level l : LEVELS) {
    if (l == null) {
      // avoid NPE
      continue;
    }
    if (logger.isLoggable(l)) {
      // return first level loggable
      return l.getName();
    }
  }
  return Level.OFF.getName();
}
 
Example 3
Source File: DefaultLevelController.java    From vespa with Apache License 2.0 6 votes vote down vote up
DefaultLevelController(String env) {
    if (LogUtil.empty(env)) {
        env = "all -debug -spam";
    }

    //level string is: fatal, error, warning, config, info, event, debug, spam
    if (env.equals("all")) {
        levelLimit = LogLevel.ALL;
        levelstring = "  ON  ON  ON  ON  ON  ON  ON  ON";
    } else {
        StringBuilder sb = new StringBuilder();
        for (Level level : LogLevel.getLevels().values()) {
            String levelName = level.getName();
            if (hasNegWord(levelName, env) || (!hasWord("all", env) && !hasWord(levelName, env))) {
                sb.append(" OFF");
            } else {
                sb.append("  ON");
                if ((level.intValue() < levelLimit.intValue())) {
                    levelLimit = level;
                }
            }
        }
        levelstring = sb.toString();
    }
    // System.err.println("default level controller levelstring: "+levelstring);
}
 
Example 4
Source File: LogMetricsHandler.java    From vespa with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a Map of log level counts (level is key and count is
 * value).
 *
 * @return A Map of log level counts
 */
public Map<String, Long> getMetricsPerLevel() {
    Map<String, Long> levelCounts = new TreeMap<String, Long>();
    // Loop through all levels summing the count for all hosts.
    for (Level level : Arrays.asList(levels)) {
        String levelName = level.getName();
        long count = 0;
        for (LevelCount levelCount : logMetrics) {
            if (levelName.equals(levelCount.getLevel().getName())) {
                count += levelCount.getCount();
            }
        }
        levelCounts.put(levelName, count);
    }
    return levelCounts;
}
 
Example 5
Source File: ComponentDemo.java    From darklaf with MIT License 5 votes vote down vote up
default JMenu createDevSettings() {
    JMenu dev = new JMenu("Dev");
    JMenu logging = new JMenu("Logging");
    ButtonGroup bg = new ButtonGroup();
    Level[] levels = new Level[]{Level.ALL, Level.FINE, Level.INFO, Level.WARNING, Level.SEVERE, Level.OFF};
    Level currentLevel = LafManager.getLogLevel();
    for (Level level : levels) {
        JRadioButtonMenuItem mi = new JRadioButtonMenuItem(level.getName());
        mi.addActionListener(e -> LafManager.setLogLevel(level));
        bg.add(mi);
        logging.add(mi);
        if (level.equals(currentLevel)) {
            mi.setSelected(true);
        }
    }
    JCheckBoxMenuItem aaPainting = new JCheckBoxMenuItem("Translucent Antialiasing");
    aaPainting.addActionListener(e -> StringPainter.setTranslucentAAPaintingEnabled(aaPainting.isSelected()));
    aaPainting.setSelected(StringPainter.isTranslucentAAPaintingEnabled());
    JCheckBoxMenuItem experimentalAA = new JCheckBoxMenuItem("Experimental Antialiasing");
    experimentalAA.addActionListener(e -> StringPainter.setExperimentalAntialiasingEnabled(experimentalAA.isSelected()));
    experimentalAA.setSelected(StringPainter.isExperimentalAntialiasingEnabled());

    dev.add(logging);
    dev.add(aaPainting);
    dev.add(experimentalAA);
    dev.add(new JCheckBoxMenuItem("Custom Decorations") {
        {
            setSelected(LafManager.isDecorationsEnabled());
            addActionListener(e -> LafManager.setDecorationsEnabled(isSelected()));
        }
    });
    return dev;
}
 
Example 6
Source File: LogViewMgr.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Map<String, String> getLevelMap() {
    Map<String, String> levelMap = new HashMap<String, String>();
    for(Level l: new Level [] { Level.ALL, Level.CONFIG, Level.FINE,
            Level.FINER, Level.FINEST, Level.INFO, Level.SEVERE, Level.WARNING } ) {
        String name = l.getName();
        levelMap.put(name, l.getLocalizedName());
    }
    return levelMap;
}
 
Example 7
Source File: LogViewMgr.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Map<String, String> getLevelMap() {
    Map<String, String> levelMap = new HashMap<String, String>();
    for(Level l: new Level [] { Level.ALL, Level.CONFIG, Level.FINE,
            Level.FINER, Level.FINEST, Level.INFO, Level.SEVERE, Level.WARNING } ) {
        String name = l.getName();
        levelMap.put(name, getLocalized(name));
    }
    return levelMap;
}
 
Example 8
Source File: LoggingCommands.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
private static String levelName(Level level) {
    if(level == Level.WARNING) {
        return "WARN";
    } else if(level == null) {
        return "parent";
    } else {
        return level.getName();
    }
}
 
Example 9
Source File: LogWriter.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public LogWriter(final InputStream stream, final String cmd, final Level level)
{
    super("LogWriter " + level.getName() + " " + cmd);
    reader = new BufferedReader(new InputStreamReader(stream));
    this.cmd = cmd;
    this.level = level;
    setDaemon(true);
}
 
Example 10
Source File: LogViewer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
public LogLevelMenu() {
	super("log_level");

	for (final Level level : LogViewer.SELECTABLE_LEVELS) {
		JMenuItem item = new JMenuItem(new LoggedAbstractAction(level.getName()) {

			private static final long serialVersionUID = 1L;

			@Override
			public void loggedActionPerformed(ActionEvent e) {
				new Thread(new Runnable() {

					@Override
					public void run() {
						// change the log level outside the EDT
						// no progress thread because the part that may take some time (the
						// GUI refresh by Swing) cannot be cancelled anyway
						setLogLevel(level);
					}
				}).start();
			}
		});

		// highlight current log level
		if (getLogSelectionModel().getCurrentLogModel() != null) {
			if (level.equals(getLogSelectionModel().getCurrentLogModel().getLogLevel())) {
				item.setFont(item.getFont().deriveFont(Font.BOLD));
			}
		}
		add(item);
	}
}
 
Example 11
Source File: RenderedDebugLevel.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static RenderedDebugLevel of(Level level, boolean selected) {
	RenderedDebugLevel output = new RenderedDebugLevel();
	output.name = level.getName();
	output.selected = selected;
	return output;
}
 
Example 12
Source File: LoggingConfigurationTestBase.java    From appengine-tck with Apache License 2.0 4 votes vote down vote up
private String createMessage(Level lev, long start) {
    return "Log message at level " + lev.getName() + " (" + start + ")";
}
 
Example 13
Source File: LogLevelMapping.java    From selenium with Apache License 2.0 2 votes vote down vote up
/**
 * Converts the JDK level to a name supported by Selenium.
 *
 * @param level log level to get the string name of
 * @return string name representation of the level selenium supports
 */
public static String getName(Level level) {
  Level normalized = normalize(level);
  return normalized == Level.FINE ? DEBUG : normalized.getName();
}