当前位置: 首页>>代码示例>>Java>>正文


Java Log.isTraceEnabled方法代码示例

本文整理汇总了Java中org.apache.commons.logging.Log.isTraceEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java Log.isTraceEnabled方法的具体用法?Java Log.isTraceEnabled怎么用?Java Log.isTraceEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.logging.Log的用法示例。


在下文中一共展示了Log.isTraceEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:41,代码来源:RMServerUtils.java

示例2: 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...");
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:68,代码来源:HttpRangeProcessor.java

示例3: isLogEnabled

import org.apache.commons.logging.Log; //导入方法依赖的package包/类
/**
 * Determine whether the given {@link Log} instance is enabled.
 * <p>Default is {@code true} when the "trace" level is enabled.
 * Subclasses can override this to change the level under which 'tracing' occurs.
 * @param logger the {@code Log} instance to check
 */
protected boolean isLogEnabled(Log logger) {
	return logger.isTraceEnabled();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractTraceInterceptor.java

示例4: 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));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:SwiftUtils.java


注:本文中的org.apache.commons.logging.Log.isTraceEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。