File Source: Logger.java

     1  /*
     2   * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
     3   *
     4   * Permission is hereby granted, free of charge, to any person obtaining a copy
     5   * of this software and associated documentation files (the "Software"), to deal
     6   * in the Software without restriction, including without limitation the rights
     7   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     8   * copies of the Software, and to permit persons to whom the Software is
     9   * furnished to do so, subject to the following conditions:
    10   *
    11   * The above copyright notice and this permission notice shall be included in
    12   * all copies or substantial portions of the Software.
    13   *
    14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    20   * SOFTWARE.
    21   */
    22  
    23  package com.dmdirc.logger;
    24  
    25  /**
    26   * Logger class for the application.
    27   */
    28  public final class Logger {
    29  
    30      /** The manager to use to report errors. */
             /* 
    P/P       *  Method: com.dmdirc.logger.Logger__static_init
              * 
              *  Postconditions:
              *    manager == &com.dmdirc.logger.ErrorManager__static_init.new ErrorManager(ErrorManager__static_init#1)
              */
    31      protected static final ErrorManager manager = ErrorManager.getErrorManager();
    32         
    33      /** Prevent instantiation of a new instance of Logger. */
             /* 
    P/P       *  Method: void com.dmdirc.logger.Logger()
              */
    34      private Logger() {
    35          //Ignore
    36      }
    37      
    38      /**
    39       * Called when a user correctable error occurs.
    40       *
    41       * @param level Severity of the error
    42       * @param message Brief error description
    43       */
    44      public static void userError(final ErrorLevel level, final String message) {
                 /* 
    P/P           *  Method: void userError(ErrorLevel, String)
                  * 
                  *  Preconditions:
                  *    init'ed(manager.logReports)
                  *    manager.nextErrorID != null
                  *    level != null
                  *    message != null
                  *    (soft) init'ed(manager.sendReports)
                  *    (soft) init'ed(com.dmdirc.ui.FatalErrorDialog$4__static_init.new int[](FatalErrorDialog$4__static_init#1)[...])
                  *    (soft) init'ed(manager.reportThread)
                  *    (soft) init'ed(com/dmdirc/logger/ProgramError.errorDir)
                  * 
                  *  Postconditions:
                  *    com/dmdirc/logger/ProgramError.errorDir == One-of{old com/dmdirc/logger/ProgramError.errorDir, &new File(getErrorFile#1)}
                  *    init'ed(com/dmdirc/logger/ProgramError.errorDir)
                  *    manager.reportThread == old manager.reportThread
                  *    init'ed(manager.reportThread)
                  *    new ErrorReportingThread(sendError#1) num objects == 0
                  *    init'ed(new ErrorReportingThread(sendError#1).queue)
                  *    new File(getErrorFile#1) num objects <= 1
                  */
    45          manager.addError(level, message);
    46      }
    47      
    48      /**
    49       * Called when a user correctable error occurs.
    50       *
    51       * @param level Severity of the error
    52       * @param message Brief error description
    53       * @param details Verbose description of the error
    54       */
    55      public static void userError(final ErrorLevel level, final String message,
    56              final String details) {
                 /* 
    P/P           *  Method: void userError(ErrorLevel, String, String)
                  * 
                  *  Preconditions:
                  *    init'ed(manager.logReports)
                  *    manager.nextErrorID != null
                  *    level != null
                  *    message != null
                  *    (soft) init'ed(manager.sendReports)
                  *    (soft) init'ed(com.dmdirc.ui.FatalErrorDialog$4__static_init.new int[](FatalErrorDialog$4__static_init#1)[...])
                  *    (soft) init'ed(manager.reportThread)
                  *    (soft) init'ed(com/dmdirc/logger/ProgramError.errorDir)
                  * 
                  *  Postconditions:
                  *    com/dmdirc/logger/ProgramError.errorDir == One-of{old com/dmdirc/logger/ProgramError.errorDir, &amp;new File(getErrorFile#1)}
                  *    init'ed(com/dmdirc/logger/ProgramError.errorDir)
                  *    manager.reportThread == old manager.reportThread
                  *    init'ed(manager.reportThread)
                  *    new ErrorReportingThread(sendError#1) num objects == 0
                  *    init'ed(new ErrorReportingThread(sendError#1).queue)
                  *    new File(getErrorFile#1) num objects <= 1
                  */
    57          manager.addError(level, message, new String[]{details}, false);
    58      }
    59      
    60      /**
    61       * Called when a user correctable error occurs.
    62       *
    63       * @param level Severity of the error
    64       * @param message Brief error description
    65       * @param exception Throwable cause for the error
    66       */
    67      public static void userError(final ErrorLevel level,
    68              final String message, final Throwable exception) {
                 /* 
    P/P           *  Method: void userError(ErrorLevel, String, Throwable)
                  * 
                  *  Preconditions:
                  *    init'ed(manager.logReports)
                  *    manager.nextErrorID != null
                  *    level != null
                  *    message != null
                  *    (soft) com.dmdirc.logger.ErrorManager__static_init.new Class[](ErrorManager__static_init#2)[...] != null
                  *    (soft) init'ed(manager.sendReports)
                  *    (soft) init'ed(com.dmdirc.ui.FatalErrorDialog$4__static_init.new int[](FatalErrorDialog$4__static_init#1)[...])
                  *    (soft) init'ed(manager.reportThread)
                  *    (soft) init'ed(com/dmdirc/logger/ProgramError.errorDir)
                  * 
                  *  Postconditions:
                  *    com/dmdirc/logger/ProgramError.errorDir == One-of{old com/dmdirc/logger/ProgramError.errorDir, &amp;new File(getErrorFile#1)}
                  *    init'ed(com/dmdirc/logger/ProgramError.errorDir)
                  *    manager.reportThread == old manager.reportThread
                  *    init'ed(manager.reportThread)
                  *    new ErrorReportingThread(sendError#1) num objects == 0
                  *    init'ed(new ErrorReportingThread(sendError#1).queue)
                  *    new File(getErrorFile#1) num objects <= 1
                  */
    69          manager.addError(level, message, exception, false);
    70      }
    71      
    72      /**
    73       * Called when a non user correctable error occurs, the error will be
    74       * logged and optionally sent to the developers.
    75       *
    76       * @param level Severity of the error
    77       * @param message Brief error description
    78       * @param exception Cause of error
    79       */
    80      public static void appError(final ErrorLevel level,
    81              final String message, final Throwable exception) {
                 /* 
    P/P           *  Method: void appError(ErrorLevel, String, Throwable)
                  * 
                  *  Preconditions:
                  *    init'ed(manager.logReports)
                  *    manager.nextErrorID != null
                  *    level != null
                  *    message != null
                  *    (soft) com.dmdirc.logger.ErrorManager__static_init.new Class[](ErrorManager__static_init#2)[...] != null
                  *    (soft) init'ed(manager.sendReports)
                  *    (soft) init'ed(com.dmdirc.ui.FatalErrorDialog$4__static_init.new int[](FatalErrorDialog$4__static_init#1)[...])
                  *    (soft) init'ed(manager.reportThread)
                  *    (soft) init'ed(com/dmdirc/logger/ProgramError.errorDir)
                  * 
                  *  Postconditions:
                  *    com/dmdirc/logger/ProgramError.errorDir == One-of{old com/dmdirc/logger/ProgramError.errorDir, &amp;new File(getErrorFile#1)}
                  *    init'ed(com/dmdirc/logger/ProgramError.errorDir)
                  *    manager.reportThread == One-of{old manager.reportThread, &amp;new ErrorReportingThread(sendError#1)}
                  *    init'ed(manager.reportThread)
                  *    new ErrorReportingThread(sendError#1) num objects <= 1
                  *    init'ed(new ErrorReportingThread(sendError#1).queue)
                  *    new File(getErrorFile#1) num objects <= 1
                  */
    82          manager.addError(level, message, exception, true);
    83      }
    84      
    85      /**
    86       * Asserts that the specified value is true. If not, an AssertionError
    87       * exception is thrown.
    88       * 
    89       * @param value The value to be tested
    90       */
    91      public static void assertTrue(final boolean value) {
                 /* 
    P/P           *  Method: void assertTrue(bool)
                  * 
                  *  Preconditions:
                  *    value == 1
                  */
    92          if (!value) {
    93              throw new AssertionError();
    94          }
    95      }
    96      
    97  }








SofCheck Inspector Build Version : 2.17854
Logger.java 2009-Jun-25 01:54:24
Logger.class 2009-Sep-02 17:04:16