本文整理汇总了Java中org.apache.commons.logging.Log.trace方法的典型用法代码示例。如果您正苦于以下问题:Java Log.trace方法的具体用法?Java Log.trace怎么用?Java Log.trace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.logging.Log
的用法示例。
在下文中一共展示了Log.trace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logInvasionHierarchy
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Puts information about current <code>childRef</code> and its <code>parentRef</code> into log in TRACE level. Information includes 'name', 'fromRepositoryId', 'aliened' and
* 'invadedBy' properties. Additionally, collects the same information for children of <code>childRef</code>
*
* @param parentRef - {@link NodeRef} instance of child node
* @param childRef - {@link NodeRef} instance of parent of the <code>childRef</code>
* @param nodeService - {@link NodeService} instance to get properties and checking other states
* @param log - {@link Log} instance to put log for appropriate class
*/
protected void logInvasionHierarchy(NodeRef parentRef, NodeRef childRef, NodeService nodeService, Log log)
{
Map<QName, Serializable> properties = nodeService.getProperties(childRef);
Map<QName, Serializable> parentProperties = nodeService.getProperties(parentRef);
StringBuilder message = new StringBuilder("Information about '").append(properties.get(ContentModel.PROP_NAME)).append("' node:\n fromRepositoryId: ").append(
properties.get(TransferModel.PROP_FROM_REPOSITORY_ID)).append("\n").append(" invadedBy: ").append(properties.get(TransferModel.PROP_INVADED_BY)).append("\n")
.append(" alien: ").append(nodeService.hasAspect(childRef, TransferModel.ASPECT_ALIEN)).append("\n").append(" repositoryId: ").append(
properties.get(TransferModel.PROP_REPOSITORY_ID)).append("\n").append(" parent: ").append(parentProperties.get(ContentModel.PROP_NAME)).append("(")
.append(parentProperties.get(TransferModel.PROP_FROM_REPOSITORY_ID)).append(")").append(parentProperties.get(TransferModel.PROP_INVADED_BY)).append(": ").append(
nodeService.hasAspect(parentRef, TransferModel.ASPECT_ALIEN)).append("\n").append(" children:\n");
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(childRef);
if ((null != childAssocs) && !childAssocs.isEmpty())
{
for (ChildAssociationRef child : childAssocs)
{
properties = nodeService.getProperties(child.getChildRef());
message.append(" ").append(properties.get(ContentModel.PROP_NAME)).append("(").append(properties.get(TransferModel.PROP_FROM_REPOSITORY_ID)).append(")")
.append(properties.get(TransferModel.PROP_INVADED_BY)).append(": ").append(nodeService.hasAspect(child.getChildRef(), TransferModel.ASPECT_ALIEN)).append(
"\n");
}
}
log.trace(message.toString());
}
示例2: invokeUnderTrace
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String invocationDescription = getInvocationDescription(invocation);
logger.trace("Entering " + invocationDescription);
try {
Object rval = invocation.proceed();
logger.trace("Exiting " + invocationDescription);
return rval;
}
catch (Throwable ex) {
logger.trace("Exception thrown in " + invocationDescription, ex);
throw ex;
}
}
示例3: writeToLog
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Writes the supplied message and {@link Throwable} to the
* supplied {@code Log} instance. By default messages are written
* at {@code TRACE} level. Sub-classes can override this method
* to control which level the message is written at.
*/
protected void writeToLog(Log logger, String message, Throwable ex) {
if (ex != null) {
logger.trace(message, ex);
}
else {
logger.trace(message);
}
}
示例4: invokeUnderTrace
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Wraps the invocation with a JAMon Monitor and writes the current
* performance statistics to the log (if enabled).
* @see com.jamonapi.MonitorFactory#start
* @see com.jamonapi.Monitor#stop
*/
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = createInvocationTraceName(invocation);
Monitor monitor = MonitorFactory.start(name);
try {
return invocation.proceed();
}
finally {
monitor.stop();
if (!this.trackAllInvocations || isLogEnabled(logger)) {
logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor);
}
}
}
示例5: invokeUnderTrace
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = createInvocationTraceName(invocation);
StopWatch stopWatch = new StopWatch(name);
stopWatch.start(name);
try {
return invocation.proceed();
}
finally {
stopWatch.stop();
logger.trace(stopWatch.shortSummary());
}
}
示例6: verifyAdminAccess
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Utility method to verify if the current user has access based on the
* passed {@link AccessControlList}
* @param authorizer the {@link AccessControlList} to check against
* @param method the method name to be logged
* @param module like AdminService or NodeLabelManager
* @param LOG the logger to use
* @return {@link UserGroupInformation} of the current user
* @throws IOException
*/
public static UserGroupInformation verifyAdminAccess(
YarnAuthorizationProvider authorizer, String method, String module,
final Log LOG)
throws IOException {
UserGroupInformation user;
try {
user = UserGroupInformation.getCurrentUser();
} catch (IOException ioe) {
LOG.warn("Couldn't get current user", ioe);
RMAuditLogger.logFailure("UNKNOWN", method, "",
"AdminService", "Couldn't get current user");
throw ioe;
}
if (!authorizer.isAdmin(user)) {
LOG.warn("User " + user.getShortUserName() + " doesn't have permission" +
" to call '" + method + "'");
RMAuditLogger.logFailure(user.getShortUserName(), method, "", module,
RMAuditLogger.AuditConstants.UNAUTHORIZED_USER);
throw new AccessControlException("User " + user.getShortUserName() +
" doesn't have permission" +
" to call '" + method + "'");
}
if (LOG.isTraceEnabled()) {
LOG.trace(method + " invoked by user " + user.getShortUserName());
}
return user;
}
示例7: streamRangeBytes
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Stream a range of bytes from the given InputStream to the ServletOutputStream
*
* @param r Byte Range to process
* @param is InputStream
* @param os ServletOutputStream
* @param offset Assumed InputStream position - to calculate skip bytes from
*
*/
private void streamRangeBytes(final Range r, final InputStream is, final OutputStream os, long offset)
throws IOException
{
final Log logger = getLogger();
final boolean trace = logger.isTraceEnabled();
// TODO: investigate using getFileChannel() on ContentReader
if (r.start != 0L && r.start > offset)
{
long skipped = offset + is.skip(r.start - offset);
if (skipped < r.start)
{
// Nothing left to download!
return;
}
}
long span = (r.end - r.start) + 1L;
long bytesLeft = span;
int read = 0;
// Check that bytesLeft isn't greater than int can hold
int bufSize;
if (bytesLeft >= Integer.MAX_VALUE - 8)
{
bufSize = CHUNKSIZE;
}
else
{
bufSize = ((int)bytesLeft) < CHUNKSIZE ? (int)bytesLeft : CHUNKSIZE;
}
byte[] buf = new byte[bufSize];
while ((read = is.read(buf)) > 0 && bytesLeft != 0L)
{
os.write(buf, 0, read);
bytesLeft -= (long)read;
if (bytesLeft != 0L)
{
int resize;
if (bytesLeft >= Integer.MAX_VALUE - 8)
{
resize = CHUNKSIZE;
}
else
{
resize = ((int)bytesLeft) < CHUNKSIZE ? (int)bytesLeft : CHUNKSIZE;
}
if (resize != buf.length)
{
buf = new byte[resize];
}
}
if (trace) logger.trace("...wrote " + read + " bytes, with " + bytesLeft + " to go...");
}
}
示例8: trace
import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
* Sprintf() to the log iff the log is at trace level. If the log
* is not at trace level, the printf operation is skipped, so
* no time is spent generating the string.
* @param log log to use
* @param text text message
* @param args args arguments to the print statement
*/
public static void trace(Log log, String text, Object... args) {
if (log.isTraceEnabled()) {
log.trace(String.format(text, args));
}
}