use of java.util.logging.Handler in project grpc-java by grpc.
the class ContextTest method detachingNonCurrentLogsSevereMessage.
@Test
public void detachingNonCurrentLogsSevereMessage() {
final AtomicReference<LogRecord> logRef = new AtomicReference<LogRecord>();
Handler handler = new Handler() {
@Override
public void publish(LogRecord record) {
logRef.set(record);
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
};
Logger logger = Logger.getLogger(Context.storage().getClass().getName());
try {
logger.addHandler(handler);
Context initial = Context.current();
Context base = initial.withValue(PET, "dog");
// Base is not attached
base.detach(initial);
assertSame(initial, Context.current());
assertNotNull(logRef.get());
assertEquals(Level.SEVERE, logRef.get().getLevel());
} finally {
logger.removeHandler(handler);
}
}
use of java.util.logging.Handler in project jmonkeyengine by jMonkeyEngine.
the class TestCanvas method main.
public static void main(String[] args) {
JmeFormatter formatter = new JmeFormatter();
Handler consoleHandler = new ConsoleHandler();
consoleHandler.setFormatter(formatter);
Logger.getLogger("").removeHandler(Logger.getLogger("").getHandlers()[0]);
Logger.getLogger("").addHandler(consoleHandler);
createCanvas(appClass);
try {
Thread.sleep(500);
} catch (InterruptedException ex) {
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
createFrame();
currentPanel.add(canvas, BorderLayout.CENTER);
frame.pack();
startApp();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
});
}
use of java.util.logging.Handler in project jmonkeyengine by jMonkeyEngine.
the class AndroidHarness method initializeLogHandler.
/**
* Removes the standard Android log handler due to an issue with not logging
* entries lower than INFO level and adds a handler that produces
* JME formatted log messages.
*/
protected void initializeLogHandler() {
Logger log = LogManager.getLogManager().getLogger("");
for (Handler handler : log.getHandlers()) {
if (log.getLevel() != null && log.getLevel().intValue() <= Level.FINE.intValue()) {
Log.v("AndroidHarness", "Removing Handler class: " + handler.getClass().getName());
}
log.removeHandler(handler);
}
Handler handler = new AndroidLogHandler();
log.addHandler(handler);
handler.setLevel(Level.ALL);
}
use of java.util.logging.Handler in project jmonkeyengine by jMonkeyEngine.
the class AndroidHarnessFragment method initializeLogHandler.
/**
* Removes the standard Android log handler due to an issue with not logging
* entries lower than INFO level and adds a handler that produces
* JME formatted log messages.
*/
protected void initializeLogHandler() {
Logger log = LogManager.getLogManager().getLogger("");
for (Handler handler : log.getHandlers()) {
if (log.getLevel() != null && log.getLevel().intValue() <= Level.FINE.intValue()) {
Log.v("AndroidHarness", "Removing Handler class: " + handler.getClass().getName());
}
log.removeHandler(handler);
}
Handler handler = new AndroidLogHandler();
log.addHandler(handler);
handler.setLevel(Level.ALL);
}
use of java.util.logging.Handler in project hudson-2.x by hudson.
the class WeakLogHandler method setFormatter.
@Override
public void setFormatter(Formatter newFormatter) throws SecurityException {
super.setFormatter(newFormatter);
Handler t = resolve();
if (t != null)
t.setFormatter(newFormatter);
}
Aggregations