logrecord.java

来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 676 行 · 第 1/2 页

JAVA
676
字号
    {
      if (resourceBundleName != null)
	bundle = ResourceBundle.getBundle(resourceBundleName);
    }
    catch (java.util.MissingResourceException _)
    {
    }
  }


  /**
   * Returns the level of the LogRecord.
   *
   * <p>Applications should be aware of the possibility that the
   *  result is not necessarily one of the standard logging levels,
   *  since the logging framework allows to create custom subclasses
   *  of <code>java.util.logging.Level</code>.  Therefore, filters
   *  should perform checks like <code>theRecord.getLevel().intValue()
   *  == Level.INFO.intValue()</code> instead of <code>theRecord.getLevel()
   *  == Level.INFO</code>.
   */
  public Level getLevel()
  {
    return level;
  }


  /**
   * Sets the severity level of this <code>LogRecord</code> to a new
   * value.
   *
   * <p>As soon as a <code>LogRecord</code> has been handed over
   * to the logging framework, applications should not modify it
   * anymore.  Therefore, this method should only be called on
   * freshly constructed LogRecords.
   *
   * @param level the new severity level, for example
   *              <code>Level.WARNING</code>.
   */
  public void setLevel(Level level)
  {
    this.level = level;
  }


  /**
   * The last used sequence number for any LogRecord.
   */
  private static long lastSeqNum = 0;


  /**
   * Allocates a sequence number for a new LogRecord.  This class
   * method is only called by the LogRecord constructor.
   */
  private synchronized static long allocateSeqNum()
  {
    lastSeqNum += 1;
    return lastSeqNum;
  }


  /**
   * Returns the sequence number of this <code>LogRecord</code>.
   */
  public long getSequenceNumber()
  {
    return sequenceNumber;
  }


  /**
   * Sets the sequence number of this <code>LogRecord</code> to a new
   * value.
   *
   * <p>As soon as a <code>LogRecord</code> has been handed over
   * to the logging framework, applications should not modify it
   * anymore.  Therefore, this method should only be called on
   * freshly constructed LogRecords.
   *
   * @param seqNum the new sequence number.
   */
  public void setSequenceNumber(long seqNum)
  {
    this.sequenceNumber = seqNum;
  }


  /**
   * Returns the name of the class where the event being logged
   * has had its origin.  This information can be passed as
   * parameter to some logging calls, and in certain cases, the
   * logging framework tries to determine an approximation
   * (which may or may not be accurate).
   * 
   * @return the name of the class that issued the logging request,
   *         or <code>null</code> if this information could not
   *         be obtained.
   */
  public String getSourceClassName()
  {
    if (sourceClassName != null)
      return sourceClassName;

    /*  FIXME: Should infer this information from the call stack. */
    return null;
  }


  /**
   * Sets the name of the class where the event being logged
   * has had its origin.
   *
   * <p>As soon as a <code>LogRecord</code> has been handed over
   * to the logging framework, applications should not modify it
   * anymore.  Therefore, this method should only be called on
   * freshly constructed LogRecords.
   * 
   * @param sourceClassName the name of the class that issued the
   *          logging request, or <code>null</code> to indicate that
   *          this information could not be obtained.
   */
  public void setSourceClassName(String sourceClassName)
  {
    this.sourceClassName = sourceClassName;
  }


  /**
   * Returns the name of the method where the event being logged
   * has had its origin.  This information can be passed as
   * parameter to some logging calls, and in certain cases, the
   * logging framework tries to determine an approximation
   * (which may or may not be accurate).
   * 
   * @return the name of the method that issued the logging request,
   *         or <code>null</code> if this information could not
   *         be obtained.
   */
  public String getSourceMethodName()
  {
    if (sourceMethodName != null)
      return sourceMethodName;

    /* FIXME: Should infer this information from the call stack. */
    return null;
  }


  /**
   * Sets the name of the method where the event being logged
   * has had its origin.
   *
   * <p>As soon as a <code>LogRecord</code> has been handed over
   * to the logging framework, applications should not modify it
   * anymore.  Therefore, this method should only be called on
   * freshly constructed LogRecords.
   * 
   * @param sourceMethodName the name of the method that issued the
   *          logging request, or <code>null</code> to indicate that
   *          this information could not be obtained.
   */
  public void setSourceMethodName(String sourceMethodName)
  {
    this.sourceMethodName = sourceMethodName;
  }


  /**
   * Returns the message for this <code>LogRecord</code> before
   * any localization or parameter substitution.
   *
   * <p>A {@link Logger} will try to localize the message
   * if a resource bundle has been associated with this
   * <code>LogRecord</code>.  In this case, the logger will call
   * <code>getMessage()</code> and use the result as the key
   * for looking up the localized message in the bundle.
   * If no bundle has been associated, or if the result of
   * <code>getMessage()</code> is not a valid key in the
   * bundle, the logger will use the raw message text as
   * returned by this method.
   *
   * @return the message text, or <code>null</code> if there
   *         is no message text.
   */
  public String getMessage()
  {
    return message;
  }


  /**
   * Sets the message for this <code>LogRecord</code>.
   *
   * <p>A <code>Logger</code> will try to localize the message
   * if a resource bundle has been associated with this
   * <code>LogRecord</code>.  In this case, the logger will call
   * <code>getMessage()</code> and use the result as the key
   * for looking up the localized message in the bundle.
   * If no bundle has been associated, or if the result of
   * <code>getMessage()</code> is not a valid key in the
   * bundle, the logger will use the raw message text as
   * returned by this method.
   *
   * <p>It is possible to set the message to either an empty String or
   * <code>null</code>, although this does not make the the message
   * very helpful to human users.
   *
   * @param message the message text (which will be used as key
   *                for looking up the localized message text
   *                if a resource bundle has been associated). 
   */
  public void setMessage(String message)
  {
    this.message = message;
  }


  /**
   * Returns the parameters to the log message.
   *
   * @return the parameters to the message, or <code>null</code> if
   *         the message has no parameters.
   */
  public Object[] getParameters()
  {
    return parameters;
  }


  /**
   * Sets the parameters to the log message.
   *
   * <p>As soon as a <code>LogRecord</code> has been handed over
   * to the logging framework, applications should not modify it
   * anymore.  Therefore, this method should only be called on
   * freshly constructed LogRecords.
   *
   * @param parameters the parameters to the message, or <code>null</code>
   *                   to indicate that the message has no parameters.
   */
  public void setParameters(Object[] parameters)
  {
    this.parameters = parameters;
  }


  /**
   * Returns an identifier for the thread in which this
   * <code>LogRecord</code> was created.  The identifier is not
   * necessarily related to any thread identifiers used by the
   * operating system.
   *
   * @return an identifier for the source thread.
   */
  public int getThreadID()
  {
    return threadID;
  }


  /**
   * Sets the identifier indicating in which thread this
   * <code>LogRecord</code> was created.  The identifier is not
   * necessarily related to any thread identifiers used by the
   * operating system.
   *
   * <p>As soon as a <code>LogRecord</code> has been handed over
   * to the logging framework, applications should not modify it
   * anymore.  Therefore, this method should only be called on
   * freshly constructed LogRecords.
   *
   * @param threadID the identifier for the source thread.
   */
  public void setThreadID(int threadID)
  {
    this.threadID = threadID;
  }


  /**
   * Returns the time when this <code>LogRecord</code> was created.
   *
   * @return the time of creation in milliseconds since the beginning
   *         of January 1, 1970.
   */
  public long getMillis()
  {
    return millis;
  }


  /**
   * Sets the time when this <code>LogRecord</code> was created.
   *
   * <p>As soon as a <code>LogRecord</code> has been handed over
   * to the logging framework, applications should not modify it
   * anymore.  Therefore, this method should only be called on
   * freshly constructed LogRecords.
   *
   * @param millis the time of creation in milliseconds since the
   *               beginning of January 1, 1970.
   */
  public void setMillis(long millis)
  {
    this.millis = millis;
  }


  /**
   * Returns the Throwable associated with this <code>LogRecord</code>,
   * or <code>null</code> if the logged event is not related to an exception
   * or error.
   */
  public Throwable getThrown()
  {
    return thrown;
  }


  /**
   * Associates this <code>LogRecord</code> with an exception or error.
   *
   * <p>As soon as a <code>LogRecord</code> has been handed over
   * to the logging framework, applications should not modify it
   * anymore.  Therefore, this method should only be called on
   * freshly constructed LogRecords.
   *
   * @param thrown the exception or error to associate with, or
   *               <code>null</code> if this <code>LogRecord</code>
   *               should be made unrelated to an exception or error.
   */
  public void setThrown(Throwable thrown)
  {
    this.thrown = thrown;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?