use of java.util.logging.SimpleFormatter in project j2objc by google.
the class StreamHandlerTest method testIsLoggable_NoFilter.
/*
* Test isLoggable(), use no filter, having output stream
*/
public void testIsLoggable_NoFilter() {
StreamHandler h = new StreamHandler(new ByteArrayOutputStream(), new SimpleFormatter());
LogRecord r = new LogRecord(Level.INFO, null);
assertTrue(h.isLoggable(r));
h.setLevel(Level.WARNING);
assertFalse(h.isLoggable(r));
h.setLevel(Level.CONFIG);
assertTrue(h.isLoggable(r));
r.setLevel(Level.OFF);
h.setLevel(Level.OFF);
assertFalse(h.isLoggable(r));
}
use of java.util.logging.SimpleFormatter in project malmo by Microsoft.
the class TCPSocketHelper method setLogging.
static void setLogging(boolean log) {
logging = log;
if (log == true && filehandler == null) {
try {
filehandler = new FileHandler("TCPLog.txt");
filehandler.setFormatter(new SimpleFormatter());
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.addHandler(filehandler);
}
}
use of java.util.logging.SimpleFormatter in project jreversepro by akkumar.
the class CustomLoggerFactory method createLogger.
public static Logger createLogger() {
final Logger logger = Logger.getLogger("JReversePro");
final SimpleFormatter formatter = new SimpleFormatter();
final StreamHandler handler = new StreamHandler(System.out, formatter);
logger.addHandler(handler);
logger.setLevel(Level.FINER);
return logger;
}
use of java.util.logging.SimpleFormatter in project neo4j by neo4j.
the class SuppressOutput method java_util_logging.
public static Suppressible java_util_logging(final ByteArrayOutputStream redirectTo, Level level) {
final Handler replacement = redirectTo == null ? null : new StreamHandler(redirectTo, new SimpleFormatter());
if (replacement != null && level != null) {
replacement.setLevel(level);
}
return new Suppressible() {
@Override
public Voice suppress() {
final Logger logger = LogManager.getLogManager().getLogger("");
final Level level = logger.getLevel();
final Handler[] handlers = logger.getHandlers();
for (Handler handler : handlers) {
logger.removeHandler(handler);
}
if (replacement != null) {
logger.addHandler(replacement);
logger.setLevel(Level.ALL);
}
return new Voice(this, redirectTo) {
@Override
void restore(boolean failure) throws IOException {
for (Handler handler : handlers) {
logger.addHandler(handler);
}
logger.setLevel(level);
if (replacement != null) {
logger.removeHandler(replacement);
}
}
};
}
};
}
use of java.util.logging.SimpleFormatter in project okhttp by square.
the class Main method enableHttp2FrameLogging.
private static void enableHttp2FrameLogging() {
frameLogger = Logger.getLogger(Http2.class.getName());
frameLogger.setLevel(Level.FINE);
ConsoleHandler handler = new ConsoleHandler();
handler.setLevel(Level.FINE);
handler.setFormatter(new SimpleFormatter() {
@Override
public String format(LogRecord record) {
return Util.format("%s%n", record.getMessage());
}
});
frameLogger.addHandler(handler);
}
Aggregations