1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.creadur.whisker.plugin.maven; 20 21 import org.apache.commons.lang3.builder.ToStringBuilder; 22 import org.apache.maven.plugin.logging.Log; 23 24 /** 25 * Adapts commons logging calls to Maven. 26 */ 27 public class MojoToJCLLog implements org.apache.commons.logging.Log { 28 29 /** Maven's log */ 30 private final Log log; 31 32 /** 33 * Constructs a log than delegates to Maven. 34 * @param log not null 35 */ 36 public MojoToJCLLog(final Log log) { 37 super(); 38 this.log = log; 39 } 40 41 /** 42 * Delegates to Maven. 43 * @param message possibly null 44 * @see org.apache.commons.logging.Log#debug(java.lang.Object) 45 */ 46 public void debug(final Object message) { 47 log.debug(new ToStringBuilder(message).toString()); 48 } 49 50 /** 51 * Delegates to Maven. 52 * @param message possibly null 53 * @param t cause 54 * @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable) 55 */ 56 public void debug(final Object message, final Throwable t) { 57 log.debug(new ToStringBuilder(message).toString(), t); 58 } 59 60 /** 61 * Delegates to Maven. 62 * @param message possibly null 63 * @see org.apache.commons.logging.Log#error(java.lang.Object) 64 */ 65 public void error(final Object message) { 66 log.error(new ToStringBuilder(message).toString()); 67 } 68 69 /** 70 * Delegates to Maven. 71 * @param message possibly null 72 * @param t cause 73 * @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable) 74 */ 75 public void error(final Object message, final Throwable t) { 76 log.error(new ToStringBuilder(message).toString(), t); 77 } 78 79 /** 80 * Delegates to Maven. 81 * @param message possibly null 82 * @see org.apache.commons.logging.Log#fatal(java.lang.Object) 83 */ 84 public void fatal(final Object message) { 85 log.error(new ToStringBuilder(message).toString()); 86 } 87 88 /** 89 * Delegates to Maven. 90 * @param message possibly null 91 * @param t cause 92 * @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable) 93 */ 94 public void fatal(final Object message, final Throwable t) { 95 log.error(new ToStringBuilder(message).toString(), t); 96 } 97 98 /** 99 * Delegates to Maven. 100 * @param message possibly null 101 * @see org.apache.commons.logging.Log#info(java.lang.Object) 102 */ 103 public void info(final Object message) { 104 log.info(new ToStringBuilder(message).toString()); 105 } 106 107 /** 108 * Delegates to Maven. 109 * @param message possibly null 110 * @param t cause 111 * @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable) 112 */ 113 public void info(final Object message, final Throwable t) { 114 log.info(new ToStringBuilder(message).toString(), t); 115 } 116 117 /** 118 * Delegates to Maven. 119 * @return true when debug is enabled in Maven 120 * @see org.apache.commons.logging.Log#isDebugEnabled() 121 */ 122 public boolean isDebugEnabled() { 123 return log.isDebugEnabled(); 124 } 125 126 /** 127 * Delegates to Maven. 128 * @return true when error is enabled in Maven 129 * @see org.apache.commons.logging.Log#isErrorEnabled() 130 */ 131 public boolean isErrorEnabled() { 132 return log.isErrorEnabled(); 133 } 134 135 /** 136 * Delegates to Maven. 137 * @return true when error is enabled in Maven 138 * @see org.apache.commons.logging.Log#isFatalEnabled() 139 */ 140 public boolean isFatalEnabled() { 141 return log.isErrorEnabled(); 142 } 143 144 /** 145 * Delegates to Maven. 146 * @return true when info is enabled in Maven 147 * @see org.apache.commons.logging.Log#isInfoEnabled() 148 */ 149 public boolean isInfoEnabled() { 150 return log.isInfoEnabled(); 151 } 152 153 /** 154 * Delegates to Maven. 155 * @return true when trace is enabled in Maven 156 * @see org.apache.commons.logging.Log#isTraceEnabled() 157 */ 158 public boolean isTraceEnabled() { 159 return log.isDebugEnabled(); 160 } 161 162 /** 163 * Delegates to Maven. 164 * @return true when warn is enabled in Maven 165 * @see org.apache.commons.logging.Log#isWarnEnabled() 166 */ 167 public boolean isWarnEnabled() { 168 return log.isWarnEnabled(); 169 } 170 171 /** 172 * Delegates to Maven. 173 * @param message possibly null 174 * @see org.apache.commons.logging.Log#trace(java.lang.Object) 175 */ 176 public void trace(final Object message) { 177 log.debug(new ToStringBuilder(message).toString()); 178 } 179 180 /** 181 * Delegates to Maven. 182 * @param message possibly null 183 * @param t cause 184 * @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable) 185 */ 186 public void trace(final Object message, final Throwable t) { 187 log.debug(new ToStringBuilder(message).toString(), t); 188 } 189 190 /** 191 * Delegates to Maven. 192 * @param message possibly null 193 * @see org.apache.commons.logging.Log#warn(java.lang.Object) 194 */ 195 public void warn(final Object message) { 196 log.warn(new ToStringBuilder(message).toString()); 197 } 198 199 /** 200 * Delegates to Maven. 201 * @param message possibly null 202 * @param t cause 203 * @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable) 204 */ 205 public void warn(final Object message, final Throwable t) { 206 log.warn(new ToStringBuilder(message).toString(), t); 207 } 208 }