Java tutorial
/* * #%L * Mojo's Maven plugin for Cobertura * %% * Copyright (C) 2005 - 2013 Codehaus * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ package org.codehaus.mojo.cobertura.integration; import org.apache.commons.lang.Validate; import org.apache.maven.plugin.logging.Log; /** * Simplified Log level noise selector pointing to logging framework configurations * as bundled within this plugin. * * @author <a href="mailto:lj@jguru.se">Lennart Jörelid</a>, jGuru Europe AB */ public enum LogLevel { /** * Debug logging level. */ DEBUG, /** * Info logging level. */ INFO, /** * Warning logging level. */ WARNING, /** * Error logging level. */ ERROR; /** * Simple conversion method extracting the LogLevel matching the level * assigned to the supplied Log. * * @param mavenLog The non-null Log instance. * @return The LogLevel matching the existing level of the supplied mavenLog. */ public static LogLevel getMatchingLevel(final Log mavenLog) { // Check sanity Validate.notNull(mavenLog, "Cannot handle null mavenLog argument."); LogLevel toReturn; if (mavenLog.isDebugEnabled()) { toReturn = LogLevel.DEBUG; } else if (mavenLog.isInfoEnabled()) { toReturn = LogLevel.INFO; } else if (mavenLog.isWarnEnabled()) { toReturn = LogLevel.WARNING; } else { toReturn = LogLevel.ERROR; } // All done. return toReturn; } }