List of usage examples for java.util.logging Logger isLoggable
public boolean isLoggable(Level level)
From source file:pcgen.util.Logging.java
public static void replayParsedMessages() { Logger l = getLogger(); for (QueuedMessage msg : queuedMessages) { if (l.isLoggable(msg.level)) { l.log(msg.level, msg.message, msg.stackTrace); }//from ww w .ja va2 s. c o m } queuedMessageMark = -1; }
From source file:ste.xtest.net.StubURLConnection.java
/** * Stubs the connection action to the resource. It also executes the * provided <code>StubConnectionCall</code> if any. * // ww w . jav a 2s. c om * @throws IOException in case of connection errors * @throws IllegalStateException if already connected */ @Override public void connect() throws IOException { if (connected) { throw new IllegalStateException("Already connected"); } Logger LOG = Logger.getLogger("ste.xtest.net"); if (LOG.isLoggable(Level.INFO)) { LOG.info("connecting to " + url); LOG.info("request headers: " + getRequestProperties()); LOG.info("response headers: " + headers); } if (exec != null) { try { LOG.info("executing connection code"); exec.call(this); } catch (IOException x) { throw x; } catch (Exception x) { throw new IOException(x.getMessage(), x); } } connected = true; }
From source file:ste.xtest.net.StubURLConnection.java
@Override public InputStream getInputStream() throws IOException { connectIfNeeded();//from ww w .j ava 2 s . c o m if (content == null) { return null; } Logger LOG = Logger.getLogger("ste.xtest.net"); if (content instanceof String) { if (LOG.isLoggable(Level.INFO)) { LOG.info("returning input stream from provided text"); } return new ByteArrayInputStream(((String) content).getBytes()); } else if (content instanceof Path) { if (LOG.isLoggable(Level.INFO)) { LOG.info("returning input stream from file " + ((Path) content).toAbsolutePath()); } return Files.newInputStream((Path) content); } else if (content instanceof InputStream) { if (LOG.isLoggable(Level.INFO)) { LOG.info("returning input stream from reader"); } return ((InputStream) content); } if (LOG.isLoggable(Level.INFO)) { LOG.info("returning input stream from provided data"); } return new ByteArrayInputStream((byte[]) content); }