1  /*
     2   * Copyright the original author or authors.
     3   * 
     4   * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   * 
     8   *      http://www.mozilla.org/MPL/MPL-1.1.html
     9   * 
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  import org.as2lib.core.BasicClass;
    18  import org.as2lib.env.log.LogLevel;
    19  import org.as2lib.env.log.level.AbstractLogLevel;
    20  
    21  /**
    22   * {@code AbstractLogger} offers support for simple logger tasks.
    23   *
    24   * <p>Classes that extend this class are expected to / must implement the
    25   * {@link Logger} interface.
    26   *
    27   * @author Simon Wacker
    28   */
    29  class org.as2lib.env.log.logger.AbstractLogger extends BasicClass {
    30  	
    31  	/** All log messages get logged. */
    32  	public static var ALL:LogLevel = AbstractLogLevel.ALL;
    33  	
    34  	/** All log messages that are at a lower log level than debug get logged. */
    35  	public static var DEBUG:LogLevel = AbstractLogLevel.DEBUG;
    36  	
    37  	/** All log messages that are at a lower log level than info get logged. */
    38  	public static var INFO:LogLevel = AbstractLogLevel.INFO;
    39  	
    40  	/** All log messages that are at a lower log level than warning get logged. */
    41  	public static var WARNING:LogLevel = AbstractLogLevel.WARNING;
    42  	
    43  	/** All log messages that are at a lower log level than error get logged. */
    44  	public static var ERROR:LogLevel = AbstractLogLevel.ERROR;
    45  	
    46  	/** All log messages that are at a lower log level than fatal get logged. */
    47  	public static var FATAL:LogLevel = AbstractLogLevel.FATAL;
    48  	
    49  	/** No log messages get logged. */
    50  	public static var NONE:LogLevel = AbstractLogLevel.NONE;
    51  	
    52  	/** The debug level. */
    53  	private var debugLevel:LogLevel;
    54  	
    55  	/** The debug level as number. */
    56  	private var debugLevelAsNumber:Number;
    57  	
    58  	/** The info level. */
    59  	private var infoLevel:LogLevel;
    60  	
    61  	/** The info level as number. */
    62  	private var infoLevelAsNumber:Number;
    63  	
    64  	/** The warning level. */
    65  	private var warningLevel:LogLevel;
    66  	
    67  	/** The warning level as number. */
    68  	private var warningLevelAsNumber:Number;
    69  	
    70  	/** The error level. */
    71  	private var errorLevel:LogLevel;
    72  	
    73  	/** The error level as number. */
    74  	private var errorLevelAsNumber:Number;
    75  	
    76  	/** The fatal level. */
    77  	private var fatalLevel:LogLevel;
    78  	
    79  	/** The fatal level as number. */
    80  	private var fatalLevelAsNumber:Number;
    81  	
    82  	/**
    83  	 * Constructs a new {@code AbstractLogger} instance.
    84  	 *
    85  	 * <p>This class class cannot be instatiated directly. You must sub-class it first.
    86  	 * 
    87  	 * <p>This constructor initializes the level instance variables that can be used
    88  	 * for fast access. Static access is relatively slow in comparison.
    89  	 */
    90  	private function AbstractLogger(Void) {
    91  		debugLevel = DEBUG;
    92  		debugLevelAsNumber = debugLevel.toNumber();
    93  		infoLevel = INFO;
    94  		infoLevelAsNumber = infoLevel.toNumber();
    95  		warningLevel = WARNING;
    96  		warningLevelAsNumber = warningLevel.toNumber();
    97  		errorLevel = ERROR;
    98  		errorLevelAsNumber = errorLevel.toNumber();
    99  		fatalLevel = FATAL;
   100  		fatalLevelAsNumber = fatalLevel.toNumber();
   101  	}
   102  	
   103  }