Class DefaultLog

java.lang.Object
com.portal.pcm.DefaultLog

public class DefaultLog extends Object
The DefaultLog class is a convenience class for debug and error logging using the default log javapcm.log.

The JavaPCM library logs messages to this log, but the log can also be used by client applications. Use the DefualtLog.log methods to write to this log.

DefaultLog uses "flag" style log control. With flag style control, each message is tagged with a flag that specifies the error message type. Possible flag values are defined in ErrorLog. Which messages are logged is based on the log level set in the configuration file. Configure the Infranet.properties file to set the levels and enable logging. The entries are:

  • infranet.log.file: The file path (the default is javapcm.log).
  • infranet.log.level: Specifies which flags will result in a log entry.
    • 0 for none (default).
    • 1 for ERROR messages
    • 2 for ERROR and WARNING messages
    • 3 for ERROR, WARNING, and DEBUG messages
  • infranet.log.logallebuf: true to log all EBufExceptions (the default is false)

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    doLog(int control)
    Evaluates the control level to determine whether a log call will result in a log entry.
    Retrieves the DefaultLog as an InputStream.
    static boolean
    Determines if the message logged is stored in memory rather than on disk.
    static void
    log(int flags, String message)
    Logs information to the default log file.
    static void
    log(Object src, int flags, String message)
    Logs information to the default log file.
    static void
    log(Object src, int flags, String message, byte[] buf)
    Logs a message to the log file along with a hex dump of the array of bytes.
    static void
    log(Object src, int flags, String message, byte[] buf, int off, int len)
    Logs information to the default log file.
    static void
    log(Object src, int flags, Throwable thrown)
    Logs the error message retrieved from the Throwable object thrown by an error.
    static void
    log(Object src, String message)
    Logs information to the default log file.
    static void
    log(String message)
    Logs a message to the default log file.
    static void
    setFlags(int flags)
    Sets the DefaultLog message flag.
    static void
    Sets the application name.
    static void
    Sets the DefaultLog file path name.
    static void
    setWriter(Writer writer)
    Set alternative log writer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultLog

      public DefaultLog()
  • Method Details

    • setName

      public static void setName(String name)
      Sets the application name.
      Parameters:
      name - The name of the application doing the logging.
    • setPath

      public static void setPath(String path)
      Sets the DefaultLog file path name.
      Parameters:
      path - The new log path.
    • setWriter

      public static void setWriter(Writer writer)
      Set alternative log writer.
      Parameters:
      writer - New Writer to write logs
    • setFlags

      public static void setFlags(int flags)
      Sets the DefaultLog message flag.
      Parameters:
      flags - The message type.
    • log

      public static void log(String message)
      Logs a message to the default log file.
      Parameters:
      message - The message to log.
    • log

      public static void log(Object src, String message)
      Logs information to the default log file.
      Parameters:
      src - The location of the error. For example, a file name and a line number. If src is a string, it is used to describe the source. Otherwise, the name of the object class is used.
      message - The message to log.
    • log

      public static void log(int flags, String message)
      Logs information to the default log file.
      Parameters:
      flags - The DefaultLog message type.
      message - The message to log.
    • log

      public static void log(Object src, int flags, Throwable thrown)
      Logs the error message retrieved from the Throwable object thrown by an error.
      Parameters:
      src - The location of the error. For example, a file name and a line number. If src is a string, it is used to describe the source. Otherwise, the name of the object class is used.
      flags - The DefaultLog message type.
      thrown - the thrown error or exception to log.
    • log

      public static void log(Object src, int flags, String message, byte[] buf)
      Logs a message to the log file along with a hex dump of the array of bytes.
      Parameters:
      src - The location of the error. For example, a file name and a line number. If src is a string, it is used to describe the source. Otherwise, the name of the object class is used.
      flags - The DefaultLog message type.
      message - The message to log.
      buf - The array of bytes to append to the message.
    • log

      public static void log(Object src, int flags, String message, byte[] buf, int off, int len)
      Logs information to the default log file.
      Parameters:
      src - The location of the error. For example, a file name and a line number. If src is a string, it is used to describe the source. Otherwise, the name of the object class is used.
      flags - The DefaultLog message type.
      message - The message to log.
      buf - The array of bytes to append to the message.
      off - Offset into the buffer; the position at which to start the hex dump.
      len - Number of buf bytes to log.
    • log

      public static void log(Object src, int flags, String message)
      Logs information to the default log file.
      Parameters:
      src - The location of the error. For example, a file name and a line number. If src is a string, it is used to describe the source. Otherwise, the name of the object class is used.
      flags - The DefaultLog message type.
      message - The message to log.
    • getLog

      public static InputStream getLog()
      Retrieves the DefaultLog as an InputStream.
      Returns:
      An InputStream of the DefaultLog object.
    • isLogInMemory

      public static boolean isLogInMemory()
      Determines if the message logged is stored in memory rather than on disk.
      Returns:
      true if the log is in memory.
    • doLog

      public static boolean doLog(int control)
      Evaluates the control level to determine whether a log call will result in a log entry.
      Parameters:
      control - The log message flag that would be passed to the log method.
      Returns:
      true if the specified control level permits writing to the log file.