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.env.except.IllegalArgumentException; 18 import org.as2lib.env.log.LogLevel; 19 import org.as2lib.env.log.logger.SimpleHierarchicalLogger; 20 21 /** 22 * {@code RootLogger} represents the root in a logger hierarchy. 23 * 24 * <p>The name of a root logger is by default {@code "root"}. 25 * 26 * <p>You must set a log level because otherwise the level in the hierarchy could 27 * be {@code null} which could cause unexpected behavior. 28 * 29 * <p>This class is normally used in conjunction with the {@link LoggerHierarchy}. 30 * 31 * @author Simon Wacker 32 */ 33 class org.as2lib.env.log.logger.RootLogger extends SimpleHierarchicalLogger { 34 35 /** Makes the static variables of the super-class accessible through this class. */ 36 private static var __proto__:Function = SimpleHierarchicalLogger; 37 38 /** 39 * Constructs a new {@code RootLogger} instance. 40 * 41 * <p>The name is automatically set to {@code "root"}. 42 * 43 * @param level the level of this logger 44 * @throws IllegalArgumentException if the passed-in {@code level} is {@code null} 45 * or {@code undefined} 46 */ 47 public function RootLogger(level:LogLevel) { 48 super("root"); 49 setLevel(level); 50 } 51 52 /** 53 * Sets the level of this logger. 54 * 55 * <p>A level of value {@code null} or {@code undefined} is not allowed. 56 * 57 * @param level the new level of this logger 58 * @throws IllegalArgumentException when {@code level} is {@code null} or 59 * {@code undefined} 60 */ 61 public function setLevel(level:LogLevel):Void { 62 if (!level) throw new IllegalArgumentException("The instance [" + this + "] is not allowed to have a level value of null.", this, arguments); 63 super.setLevel(level); 64 } 65 66 }