當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。