madkit.kernel

## Class AgentLogger

- java.lang.Object
- - java.util.logging.Logger
  - - madkit.kernel.AgentLogger

-     public final class AgentLogger
      extends java.util.logging.Logger

  This class defines a logger specialized for MaDKit agents.
  Since:
    MaDKit 5.0.0.5
  Version:
    0.91
  Author:
    Fabien Michel

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.util.logging.Formatter` | `AGENT_FILE_FORMATTER` Defines the default file formatter as : LOG_LEVEL : message
    `static java.util.logging.Formatter` | `AGENT_FORMATTER` Defines the default formatter as : [agent's name] LOG_LEVEL : message

    - ### Fields inherited from class java.util.logging.Logger

      `global, GLOBAL_LOGGER_NAME`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addHandler(java.util.logging.Handler handler)`
    `void` | `createLogFile()` Creates a log file for this logger.
    `static void` | `createLogFiles()` Create a log file for each agent having a non `null` logger.
    `java.util.logging.Level` | `getWarningLogLevel()` Returns the log level above which MaDKit warnings are displayed for the corresponding agent.
    `void` | `log(java.util.logging.LogRecord record)`
    `static void` | `setAllLogLevels(java.util.logging.Level level)` Set all the agents' loggers to the specified level
    `void` | `setLevel(java.util.logging.Level newLevel)` Set the log level for the corresponding agent.
    `void` | `setWarningLogLevel(java.util.logging.Level warningLogLevel)` Sets the agent's log level above which MaDKit warnings are displayed
    `void` | `severeLog(java.lang.String msg)` This call bypasses any settings and always produces severe log messages.
    `void` | `severeLog(java.lang.String msg, java.lang.Throwable t)` This call bypasses any settings and always produces severe log messages which display the stack trace of the throwable if it is not `null`
    `void` | `talk(java.lang.String msg)` Log a TALK message.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.util.logging.Logger

      `config, entering, entering, entering, exiting, exiting, fine, finer, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getGlobal, getHandlers, getLevel, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, isLoggable, log, log, log, log, logp, logp, logp, logp, logrb, logrb, logrb, logrb, removeHandler, setFilter, setParent, setUseParentHandlers, severe, throwing, warning`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### AGENT_FORMATTER

          public static final java.util.logging.Formatter AGENT_FORMATTER

      Defines the default formatter as : [agent's name] LOG_LEVEL : message

    - #### AGENT_FILE_FORMATTER

          public static final java.util.logging.Formatter AGENT_FILE_FORMATTER

      Defines the default file formatter as : LOG_LEVEL : message

  - ### Method Detail

    - #### getWarningLogLevel

          public java.util.logging.Level getWarningLogLevel()

      Returns the log level above which MaDKit warnings are displayed for the corresponding agent.
      Returns:
        the warningLogLevel of the corresponding agent

    - #### setWarningLogLevel

          public void setWarningLogLevel(java.util.logging.Level warningLogLevel)

      Sets the agent's log level above which MaDKit warnings are displayed
      Parameters:
        `warningLogLevel` - the log level to set

    - #### createLogFile

          public void createLogFile()

      Creates a log file for this logger. This file will be located in the directory specified by the MaDKit property `Madkit.Option.logDirectory`, which is set to "logs" by default.

    - #### addHandler

          public void addHandler(java.util.logging.Handler handler)
                          throws java.lang.SecurityException

      Overrides:
        `addHandler` in class `java.util.logging.Logger`
      Throws:
        `java.lang.SecurityException`

    - #### talk

          public void talk(java.lang.String msg)

      Log a TALK message. This uses a special level which could be used to produce messages that will be rendered as they are, without any formatting work nor end-of-line character.

      If the logger's level is not `Level.OFF` then the given message is forwarded to all the registered output Handler objects.

      If the logger's level is `Level.OFF` then the message is only printed to `System.out`

      Parameters:
        `msg` - The string message

    - #### setLevel

          public void setLevel(java.util.logging.Level newLevel)
                        throws java.lang.SecurityException

      Set the log level for the corresponding agent.
      Overrides:
        `setLevel` in class `java.util.logging.Logger`
      Throws:
        `java.lang.SecurityException`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### log

          public void log(java.util.logging.LogRecord record)

      Overrides:
        `log` in class `java.util.logging.Logger`

    - #### severeLog

          public void severeLog(java.lang.String msg,
                       java.lang.Throwable t)

      This call bypasses any settings and always produces severe log messages which display the stack trace of the throwable if it is not `null`
      Parameters:
        `msg` - the message to display
        `t` - the related exception if any. It can be `null`

    - #### severeLog

          public void severeLog(java.lang.String msg)

      This call bypasses any settings and always produces severe log messages.
      Parameters:
        `msg` - the message to display

    - #### setAllLogLevels

          public static void setAllLogLevels(java.util.logging.Level level)

      Set all the agents' loggers to the specified level
      Parameters:
        `level` - the new level

    - #### createLogFiles

          public static void createLogFiles()

      Create a log file for each agent having a non `null` logger.
      See Also:
        `createLogFile()`

Fabien Michel, Olivier Gutknecht, Jacques Ferber - November 18 2014