001: package org.apache.maven.embedder;
002:
003: /*
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021:
022: /**
023: * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
024: * @version $Id: AbstractMavenEmbedderLogger.java 513028 2007-02-28 22:50:21Z jvanzyl $
025: */
026: public abstract class AbstractMavenEmbedderLogger implements
027: MavenEmbedderLogger {
028: private int threshold = MavenEmbedderLogger.LEVEL_INFO;
029:
030: private String name;
031:
032: public int getThreshold() {
033: return threshold;
034: }
035:
036: public void setThreshold(int threshold) {
037: this .threshold = threshold;
038: }
039:
040: public String getName() {
041: return name;
042: }
043:
044: public void debug(String message) {
045: debug(message, null);
046: }
047:
048: public boolean isDebugEnabled() {
049: return threshold <= LEVEL_DEBUG;
050: }
051:
052: public void info(String message) {
053: info(message, null);
054: }
055:
056: public boolean isInfoEnabled() {
057: return threshold <= LEVEL_INFO;
058: }
059:
060: public void warn(String message) {
061: warn(message, null);
062: }
063:
064: public boolean isWarnEnabled() {
065: return threshold <= LEVEL_WARN;
066: }
067:
068: public void error(String message) {
069: error(message, null);
070: }
071:
072: public boolean isErrorEnabled() {
073: return threshold <= LEVEL_ERROR;
074: }
075:
076: public void fatalError(String message) {
077: fatalError(message, null);
078: }
079:
080: public boolean isFatalErrorEnabled() {
081: return threshold <= LEVEL_FATAL;
082: }
083:
084: protected boolean isValidThreshold(int threshold) {
085: if (threshold == LEVEL_DEBUG) {
086: return true;
087: }
088: if (threshold == LEVEL_INFO) {
089: return true;
090: }
091: if (threshold == LEVEL_WARN) {
092: return true;
093: }
094: if (threshold == LEVEL_ERROR) {
095: return true;
096: }
097: if (threshold == LEVEL_FATAL) {
098: return true;
099: }
100: if (threshold == LEVEL_DISABLED) {
101: return true;
102: }
103:
104: return false;
105: }
106: }
|