com.h3c.util

## Enum Log

- java.lang.Object
- - java.lang.Enum<Log>
  - - com.h3c.util.Log

- All Implemented Interfaces:
    Serializable, Comparable<Log>

      public enum Log
      extends Enum<Log>

  Server-side logging. All log names should be captured in this class.

  Sample usage:

       private static final Logger log = Log.GENERAL.getLogger();

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and Description
    `BOOTSTRAP` Bootstrap category.
    `CASS` Umbrella for Cassandra services.
    `CASS_CONN` Cassandra connection checker.
    `CASS_WAL` Umbrella for Cassandra Write Ahead Log.
    `CASS_WAL_GROUP` Cassandra WAL group operations.
    `CASS_WAL_LOG` Cassandra Write Ahead Log.
    `CASS_WAL_OSD` Cassandra object serialization/deserialization.
    `CASS_WAL_REPLAY` Cassandra Write Ahead Log Replay.
    `CID` CID category.
    `DIST` Umbrella for distributed services.
    `DIST_BUS` Distributed publish-subscribe bus.
    `DIST_GROUP` Distributed group management.
    `DIST_KVS` Distributed key/value store.
    `DIST_LOCK` Distributed locks.
    `DIST_SYNC` Distributed synchronized data.
    `DIST_SYNC_ZK` Distributed synchronized data using ZooKeeper.
    `EJB_PROVIDER` EJB Provider category.
    `GENERAL` General category.
    `GUI` GUI category.
    `KEYSTONE` Keystone service.
    `NBIO` Network Buffered I/O.
    `NTG` Network Traffic Generator.
    `ROOT` Root of all loggers.
    `RS` REST API category.
    `SNMP` SNMP category.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.slf4j.Logger` | `getLogger()` Returns the logger associated with this enumeration constant.
    `String` | `getName()` Returns the Logger path name.
    `static String` | `stackTraceSnippet(Throwable t)` Returns a multi-line string consisting of the toString() of the given throwable, followed by the top `SNIPPET_DEPTH` frames of the stack trace for the given throwable.
    `static String` | `stackTraceSnippet(Throwable t, int maxDepth)` Returns a multi-line string consisting of the toString() of the given throwable, followed by the top `maxDepth` frames of the stack trace for the given throwable.
    `static Log` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
    `static Log[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

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

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### ROOT

          public static final Log ROOT

      Root of all loggers.

    - #### GENERAL

          public static final Log GENERAL

      General category.

    - #### BOOTSTRAP

          public static final Log BOOTSTRAP

      Bootstrap category.

    - #### NBIO

          public static final Log NBIO

      Network Buffered I/O.

    - #### RS

          public static final Log RS

      REST API category.

    - #### GUI

          public static final Log GUI

      GUI category.

    - #### NTG

          public static final Log NTG

      Network Traffic Generator.

    - #### CID

          public static final Log CID

      CID category.

    - #### EJB_PROVIDER

          public static final Log EJB_PROVIDER

      EJB Provider category.

    - #### SNMP

          public static final Log SNMP

      SNMP category.

    - #### KEYSTONE

          public static final Log KEYSTONE

      Keystone service.

    - #### DIST

          public static final Log DIST

      Umbrella for distributed services.

    - #### DIST_BUS

          public static final Log DIST_BUS

      Distributed publish-subscribe bus.

    - #### DIST_GROUP

          public static final Log DIST_GROUP

      Distributed group management.

    - #### DIST_KVS

          public static final Log DIST_KVS

      Distributed key/value store.

    - #### DIST_LOCK

          public static final Log DIST_LOCK

      Distributed locks.

    - #### DIST_SYNC

          public static final Log DIST_SYNC

      Distributed synchronized data.

    - #### DIST_SYNC_ZK

          public static final Log DIST_SYNC_ZK

      Distributed synchronized data using ZooKeeper.

    - #### CASS

          public static final Log CASS

      Umbrella for Cassandra services.

    - #### CASS_CONN

          public static final Log CASS_CONN

      Cassandra connection checker.

    - #### CASS_WAL

          public static final Log CASS_WAL

      Umbrella for Cassandra Write Ahead Log.

    - #### CASS_WAL_OSD

          public static final Log CASS_WAL_OSD

      Cassandra object serialization/deserialization.

    - #### CASS_WAL_GROUP

          public static final Log CASS_WAL_GROUP

      Cassandra WAL group operations.

    - #### CASS_WAL_LOG

          public static final Log CASS_WAL_LOG

      Cassandra Write Ahead Log.

    - #### CASS_WAL_REPLAY

          public static final Log CASS_WAL_REPLAY

      Cassandra Write Ahead Log Replay.

  - ### Method Detail

    - #### values

          public static Log[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (Log c : Log.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static Log valueOf(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### getLogger

          public org.slf4j.Logger getLogger()

      Returns the logger associated with this enumeration constant.
      Returns:
        the associated logger

    - #### getName

          public String getName()

      Returns the Logger path name.

      Do not use this for creating Loggers; use `getLogger()` instead.

      Returns:
        the logger path name

    - #### stackTraceSnippet

          public static String stackTraceSnippet(Throwable t)

      Returns a multi-line string consisting of the toString() of the given throwable, followed by the top `SNIPPET_DEPTH` frames of the stack trace for the given throwable. To be used when logging exceptions.

      If the throwable has a cause defined, that too will have the top few stack trace frames added to the output.

      See `stackTraceSnippet(Throwable, int)` for an example of usage.

      Parameters:
        `t` - the throwable
      Returns:
        a string containing stack trace snippet(s)

    - #### stackTraceSnippet

          public static String stackTraceSnippet(Throwable t,
                                 int maxDepth)

      Returns a multi-line string consisting of the toString() of the given throwable, followed by the top `maxDepth` frames of the stack trace for the given throwable. To be used when logging exceptions.

      An example of how this might be used:

           private static final String MSG_BAD_CALLBACK =
                "Broken code? {} caused {}";
           ...
           private void event(Event ev) {
               for (EventListener el: listeners) {
                   try {
                       el.event(ev);
                   } catch (Exception e) {
                       String who = el.getClass().getName();
                       log.warn(MSG_BAD_CALLBACK, who, Log.stackTraceSnippet(e, 3));
                   }
               }
           }

      This will result in a log message that might look something like this:

           Aug 26, 2013 12:55:10 PM com.h3c.util.LogTest snippet
           WARNING: Broken code? com.h3c.foo.FooClass caused java.lang.RuntimeException: Test Exception
             com.h3c.foo.FooClass.handleStuff(FooClass.java:65)
             com.h3c.foo.FooClass.doEvent(FooClass.java:52)
             com.h3c.bar.EventHandler.handleEvent(EventHandler.java:137)
             ...

      If the throwable has a cause defined, that too will have the top few stack trace frames added to the output.
      Parameters:
        `t` - the throwable
        `maxDepth` - the maximum number of stack frames to include
      Returns:
        a string containing stack trace snippet(s)

Copyright © 2014. All Rights Reserved.