madkit.kernel

## Class AgentLogger

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

-     public final class AgentLogger
      extends 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 Formatter` | `AGENT_FILE_FORMATTER` Defines the default file formatter as : LOG_LEVEL : message
    `static 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(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.
    `Level` | `getWarningLogLevel()` Returns the log level above which MaDKit warnings are displayed for the corresponding agent.
    `void` | `log(LogRecord record)`
    `static void` | `setAllLogLevels(Level level)` Set all the agents' loggers to the specified level
    `void` | `setLevel(Level newLevel)` Set the log level for the corresponding agent.
    `void` | `setWarningLogLevel(Level warningLogLevel)` Sets the agent's log level above which MaDKit warnings are displayed
    `void` | `severeLog(String msg)` This call bypasses any settings and always produces severe log messages.
    `void` | `severeLog(String msg, 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(String msg)` Log a TALK message.
    `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 Formatter AGENT_FORMATTER

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

    - #### AGENT_FILE_FORMATTER

          public static final Formatter AGENT_FILE_FORMATTER

      Defines the default file formatter as : LOG_LEVEL : message

  - ### Method Detail

    - #### getWarningLogLevel

          public 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(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(Handler handler)
                          throws SecurityException

      Overrides:
        `addHandler` in class `Logger`
      Throws:
        `SecurityException`

    - #### talk

          public void talk(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(Level newLevel)
                        throws SecurityException

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

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### log

          public void log(LogRecord record)

      Overrides:
        `log` in class `Logger`
      See Also:
        `Logger.log(java.util.logging.LogRecord)`

    - #### severeLog

          public void severeLog(String msg,
                       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(String msg)

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

    - #### setAllLogLevels

          public static void setAllLogLevels(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