本文整理了Java中htsjdk.samtools.util.Log
类的一些代码示例,展示了Log
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Log
类的具体详情如下:
包路径:htsjdk.samtools.util.Log
类名称:Log
[英]A wafer thin wrapper around System.err that uses var-args to make it much more efficient to call the logging methods in without having to surround every call site with calls to Log.isXXXEnabled(). All the methods on this class take a variable length list of arguments and, only if logging is enabled for the level and channel being logged to, will those arguments be toString()'d and appended together.
[中]一个包裹在系统周围的薄晶圆包装。err,它使用var args使在中调用日志方法更加高效,而不必在每个调用站点周围都调用日志。isXXXEnabled()。这个类上的所有方法都有一个可变长度的参数列表,只有在为记录到的级别和通道启用了日志记录时,这些参数才会被添加到字符串()'d并附加在一起。
代码示例来源:origin: samtools/htsjdk
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);
}
}
代码示例来源:origin: com.github.samtools/htsjdk
@Override
protected void log(final String... message) {
log.info((Object[])message);
}
}
代码示例来源:origin: PapenfussLab/gridss
private void syncEnsureNext() {
while (!isClosed.get() && buffer.isEmpty()) {
try {
log.debug(String.format("%d alignments outstanding", outstandingReads.get()));
Thread.sleep(POLL_INTERVAL);
} catch (InterruptedException e) {
log.warn(e);
return;
}
}
}
/**
代码示例来源:origin: enasequence/cramtools
private static void eofNotFound(htsjdk.samtools.cram.common.Version version) {
if (version.major >= 2 && version.minor >= 1) {
log.error("Incomplete data: EOF marker not found.");
if (quitOnMissingEOF)
System.exit(1);
} else {
log.warn("EOF marker not found, possibly incomplete file/stream.");
}
}
代码示例来源:origin: broadinstitute/picard
/**
* 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
}
代码示例来源:origin: com.github.samtools/htsjdk
/** 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;
}
}
代码示例来源:origin: enasequence/cramtools
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();
}
代码示例来源:origin: broadinstitute/picard
@Override public void uncaughtException(final Thread t, final Throwable e) {
this.throwable = e;
log.error(e, "Exception caught on thread ", t.getName());
}
}
代码示例来源:origin: broadinstitute/picard
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);
}
}
}
代码示例来源:origin: samtools/htsjdk
@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);
}
}
}
代码示例来源:origin: PapenfussLab/gridss
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 {
代码示例来源:origin: samtools/htsjdk
@BeforeClass
public void initClass() {
Log.setGlobalLogLevel(LogLevel.ERROR);
}
代码示例来源:origin: com.github.samtools/htsjdk
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()));
}
}
}
代码示例来源:origin: com.github.samtools/htsjdk
/**
* 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);
}
代码示例来源:origin: samtools/htsjdk
if (isEnabled(level)) {
StringBuffer tmp = new StringBuffer();
tmp.append(level.name())
.append('\t')
.append(getTimestamp())
.append('\t')
.append(this.className)
代码示例来源:origin: com.github.samtools/htsjdk
/**
* 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);
}
代码示例来源:origin: com.github.broadinstitute/picard
/**
* 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
}
代码示例来源:origin: samtools/htsjdk
/** 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;
}
}
代码示例来源:origin: enasequence/cramtools
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;
}
}
代码示例来源:origin: com.github.broadinstitute/picard
@Override public void uncaughtException(final Thread t, final Throwable e) {
this.throwable = e;
log.error(e, "Exception caught on thread ", t.getName());
}
}
内容来源于网络,如有侵权,请联系作者删除!