ExperimentalCodec(final BitInputStream coreBlockInputStream, final BitOutputStream coreBlockOutputStream) { super(coreBlockInputStream, coreBlockOutputStream); final String subclass = this.getClass().getName(); final String warning = String.format( "Using the experimental codec %s which is untested and scheduled for removal from the CRAM spec", subclass); final Log log = Log.getInstance(ExperimentalCodec.class); log.warn(warning); } }
@Override protected void log(final String... message) { log.info((Object[])message); } }
/** * Describes the state of a tile being processed. It is either not yet completely read, or read. */ private enum TileProcessingState { NOT_DONE_READING, DONE_READING }
/** Gets a string system property, prefixed with "samjdk." using the default * if the property does not exist or if the java.security manager raises an exception for * applications started with -Djava.security.manager . */ private static String getStringProperty(final String name, final String def) { try { return System.getProperty("samjdk." + name, def); } catch (final java.security.AccessControlException error) { log.warn(error,"java Security Manager forbids 'System.getProperty(\"" + name + "\")' , returning default value: " + def ); return def; } }
public boolean cleanUp() { log.debug("Cleaning up task ", fileNameBase); inProgressMarkerFile.delete(); failedMarkerFile.delete(); successMarkerFile.delete(); outputFile.delete(); errorFile.delete(); if (outputFiles != null) for (File file : outputFiles) file.delete(); return STATUS.NONE == status(); }
@Override public void uncaughtException(final Thread t, final Throwable e) { this.throwable = e; log.error(e, "Exception caught on thread ", t.getName()); } }
public static void awaitThreadPoolTermination(final String executorName, final ThreadPoolExecutor executorService, final Duration timeBetweenChecks) { try { while (!executorService.awaitTermination(timeBetweenChecks.getSeconds(), TimeUnit.SECONDS)) { log.info(String.format("%s waiting for job completion. Finished jobs - %d : Running jobs - %d : Queued jobs - %d", executorName, executorService.getCompletedTaskCount(), executorService.getActiveCount(), executorService.getQueue().size())); } } catch (final InterruptedException e) { log.error("Interrupted exception caught: ", e); } } }
@Test public void testLogToFile() throws IOException { final File logFile = File.createTempFile(getClass().getSimpleName(), ".tmp"); logFile.deleteOnExit(); final Log.LogLevel originalLogLevel = Log.getGlobalLogLevel(); final PrintStream originalStream = Log.getGlobalPrintStream(); try (final PrintStream stream = new PrintStream(new FileOutputStream(logFile.getPath(), true))) { Log.setGlobalPrintStream(stream); Log.setGlobalLogLevel(Log.LogLevel.DEBUG); final String words = "Hello World"; log.info(words); final List<String> list = Files.readAllLines(logFile.toPath()); Assert.assertEquals(Log.getGlobalLogLevel(), Log.LogLevel.DEBUG); Assert.assertEquals(list.size(), 1); Assert.assertTrue(list.get(0).contains(words)); } finally { Log.setGlobalLogLevel(originalLogLevel); Log.setGlobalPrintStream(originalStream); } } }
public static void ensureIndexed(File fa) throws IOException { try (ReferenceSequenceFile reference = ReferenceSequenceFileFactory.getReferenceSequenceFile(fa)) { if (!reference.isIndexed()) { String msg = String.format("Unable to find index for %1$s. Please run 'samtools faidx %1$s' or picard tools BuildBamIndex to generate an index file.", fa); log.error(msg); throw new IOException(msg); } else { log.debug(fa, " is indexed."); } } } public void ensureDictionariesMatch() throws IOException {
@BeforeClass public void initClass() { Log.setGlobalLogLevel(LogLevel.ERROR); }
public void setRefMD5(final byte[] ref) { alignmentBordersSanityCheck(ref); if (sequenceId < 0 && alignmentStart < 1) { refMD5 = new byte[16]; Arrays.fill(refMD5, (byte) 0); log.debug("Empty slice ref md5 is set."); } else { final int span = Math.min(alignmentSpan, ref.length - alignmentStart + 1); if (alignmentStart + span > ref.length + 1) throw new RuntimeException("Invalid alignment boundaries."); refMD5 = SequenceUtil.calculateMD5(ref, alignmentStart - 1, span); if (log.isEnabled(Log.LogLevel.DEBUG)) { final StringBuilder sb = new StringBuilder(); final int shoulder = 10; if (ref.length <= shoulder * 2) sb.append(new String(ref)); else { sb.append(getBrief(alignmentStart, alignmentSpan, ref, shoulder)); } log.debug(String.format("Slice md5: %s for %d:%d-%d, %s", String.format("%032x", new BigInteger(1, refMD5)), sequenceId, alignmentStart, alignmentStart + span - 1, sb.toString())); } } }
/** * Logs a Throwable and optional message parts at level error. * @param throwable an instance of Throwable that should be logged with stack trace * @param messageParts zero or more objects which should be combined, by calling toString() * to form the log message. */ public final void error(final Throwable throwable, final Object... messageParts) { emit(LogLevel.ERROR, throwable, messageParts); }
if (isEnabled(level)) { StringBuffer tmp = new StringBuffer(); tmp.append(level.name()) .append('\t') .append(getTimestamp()) .append('\t') .append(this.className)
/** * Get a Log instance to perform logging within the Class specified. Returns an instance * of this class which wraps an instance of the commons logging Log class. * @param clazz the Class which is going to be doing the logging * @return a Log instance with which to log */ public static Log getInstance(final Class<?> clazz) { return new Log(clazz); }
/** * Describes the state of a tile being processed. It is either not yet completely read, or read. */ private enum TileProcessingState { NOT_DONE_READING, DONE_READING }
/** Checks whether a string system property, prefixed with "samjdk.", exists. * If the property does not exist or if the java.security manager raises an exception for * applications started with -Djava.security.manager this method returns false. */ private static boolean hasProperty(final String name){ try { return null != System.getProperty("samjdk." + name); } catch (final java.security.AccessControlException error) { log.warn(error,"java Security Manager forbids 'System.getProperty(\"" + name + "\")' , returning false"); return false; } }
private OrderedByteArray flushStripe(ByteArrayOutputStream baos) throws InterruptedException, IOException { OrderedByteArray stripe = new OrderedByteArray(); stripe.bytes = baos.toByteArray(); log.debug(String.format("adding stripe: order=%d, ref=%d, records=%d, bytes=%d", order, refId, recordCounter, stripe.bytes.length)); stripe.order = order++; baos.reset(); recordCounter = 0; return stripe; } }
@Override public void uncaughtException(final Thread t, final Throwable e) { this.throwable = e; log.error(e, "Exception caught on thread ", t.getName()); } }