/** * Sets the level on {@code logger} to {@code newLevel}. Any child loggers currently inheriting * their level from {@code logger} will be updated recursively. * * @param newLevel the new minimum logging threshold. If null, the logger's parent level will be * used; or {@code Level.INFO} for loggers with no parent. */ synchronized void setLevelRecursively(Logger logger, Level newLevel) { int previous = logger.levelIntVal; logger.levelObjVal = newLevel; if (newLevel == null) { logger.levelIntVal = logger.parent != null ? logger.parent.levelIntVal : Level.INFO.intValue(); } else { logger.levelIntVal = newLevel.intValue(); } if (previous != logger.levelIntVal) { for (Logger child : logger.children) { if (child.levelObjVal == null) { setLevelRecursively(child, null); } } } }
public class ConsoleHandler extends StreamHandler { private static final String LEVEL_PROPERTY = "manyminds.debug.ConsoleHandler.level"; private static final String DEFAULT_LEVEL = Level.INFO.toString(); private static final String FILTER_PROPERTY = "manyminds.debug.ConsoleHandler.filter"; private static final String FORMATTER_PROPERTY = "manyminds.debug.ConsoleHandler.formatter"; private static final String DEFAULT_FORMATTER = "manyminds.debug.SimpleFormatter"; private static final String ENCODING_PROPERTY = "manyminds.debug.ConsoleHandler.encoding"; public ConsoleHandler() { super( System.err, null, LEVEL_PROPERTY, DEFAULT_LEVEL, FILTER_PROPERTY, FORMATTER_PROPERTY, DEFAULT_FORMATTER, ENCODING_PROPERTY); } public void close() { try { assureHeadWritten(); assureTailWritten(); flush(); } catch (IOException ioe) { reportError("Problems closing.", ioe, ErrorManager.CLOSE_FAILURE); } } public void publish(LogRecord record) { super.publish(record); flush(); } }