本文整理了Java中net.roboconf.core.utils.Utils.writeExceptionButDoNotUseItForLogging()
方法的一些代码示例,展示了Utils.writeExceptionButDoNotUseItForLogging()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.writeExceptionButDoNotUseItForLogging()
方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:writeExceptionButDoNotUseItForLogging
[英]Writes an exception's stack trace into a string.
#logException(Logger,Exception) has better performances and should be used for logging purpose.
[中]将异常的堆栈跟踪写入字符串。
#logException(Logger,Exception)具有更好的性能,应该用于日志记录。
代码示例来源:origin: roboconf/roboconf-platform
/**
* Details for an exception.
* @param t a throwable
* @return an object with error details
*/
public static ErrorDetails exception( Throwable t ) {
return new ErrorDetails( Utils.writeExceptionButDoNotUseItForLogging( t ), ErrorDetailsKind.EXCEPTION );
}
代码示例来源:origin: roboconf/roboconf-platform
@Override
public void run() {
final String prefix = this.errorLevel ? "-- ERROR --" : "";
BufferedReader br = null;
try {
InputStream is = this.errorLevel ? this.process.getErrorStream() : this.process.getInputStream();
br = new BufferedReader( new InputStreamReader( is, StandardCharsets.UTF_8 ));
for( String line = br.readLine(); line != null; line = br.readLine())
this.sb.append( prefix + line + "\n" );
} catch( IOException e ) {
this.logger.severe( Utils.writeExceptionButDoNotUseItForLogging( e ));
} finally {
Utils.closeQuietly( br );
}
}
}
代码示例来源:origin: roboconf/roboconf-platform
/**
* Logs an exception with the given logger and the given level.
* <p>
* Writing a stack trace may be time-consuming in some environments.
* To prevent useless computing, this method checks the current log level
* before trying to log anything.
* </p>
*
* @param logger the logger
* @param t an exception or a throwable
* @param logLevel the log level (see {@link Level})
* @param message a message to insert before the stack trace
*/
public static void logException( Logger logger, Level logLevel, Throwable t, String message ) {
if( logger.isLoggable( logLevel )) {
StringBuilder sb = new StringBuilder();
if( message != null ) {
sb.append( message );
sb.append( "\n" );
}
sb.append( writeExceptionButDoNotUseItForLogging( t ));
logger.log( logLevel, sb.toString());
}
}
代码示例来源:origin: roboconf/roboconf-platform
@Test
public void testWriteException() {
String msg = "Hello from Roboconf.";
String stackTrace = Utils.writeExceptionButDoNotUseItForLogging( new Exception( msg ));
Assert.assertTrue( stackTrace.contains( msg ));
}
内容来源于网络,如有侵权,请联系作者删除!