diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging')
2 files changed, 354 insertions, 0 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java b/framework/src/maven/apache-maven-3.3.3/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java new file mode 100644 index 00000000..8d3bf1f9 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/Log.java @@ -0,0 +1,158 @@ +package org.apache.maven.plugin.logging; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +/** + * This interface supplies the API for providing feedback to the user from the <code>Mojo</code>, using standard + * <code>Maven</code> channels. + * <br/> + * There should be no big surprises here, although you may notice that the methods accept + * <code>java.lang.CharSequence</code> rather than <code>java.lang.String</code>. This is provided mainly as a + * convenience, to enable developers to pass things like <code>java.lang.StringBuffer</code> directly into the logger, + * rather than formatting first by calling <code>toString()</code>. + * + * @author jdcasey + */ +public interface Log +{ + /** + * @return true if the <b>debug</b> error level is enabled + */ + boolean isDebugEnabled(); + + /** + * Send a message to the user in the <b>debug</b> error level. + * + * @param content + */ + void debug( CharSequence content ); + + /** + * Send a message (and accompanying exception) to the user in the <b>debug</b> error level. + * <br/> + * The error's stacktrace will be output when this error level is enabled. + * + * @param content + * @param error + */ + void debug( CharSequence content, Throwable error ); + + /** + * Send an exception to the user in the <b>debug</b> error level. + * <br/> + * The stack trace for this exception will be output when this error level is enabled. + * + * @param error + */ + void debug( Throwable error ); + + /** + * @return true if the <b>info</b> error level is enabled + */ + boolean isInfoEnabled(); + + /** + * Send a message to the user in the <b>info</b> error level. + * + * @param content + */ + void info( CharSequence content ); + + /** + * Send a message (and accompanying exception) to the user in the <b>info</b> error level. + * <br/> + * The error's stacktrace will be output when this error level is enabled. + * + * @param content + * @param error + */ + void info( CharSequence content, Throwable error ); + + /** + * Send an exception to the user in the <b>info</b> error level. + * <br/> + * The stack trace for this exception will be output when this error level is enabled. + * + * @param error + */ + void info( Throwable error ); + + /** + * @return true if the <b>warn</b> error level is enabled + */ + boolean isWarnEnabled(); + + /** + * Send a message to the user in the <b>warn</b> error level. + * + * @param content + */ + void warn( CharSequence content ); + + /** + * Send a message (and accompanying exception) to the user in the <b>warn</b> error level. + * <br/> + * The error's stacktrace will be output when this error level is enabled. + * + * @param content + * @param error + */ + void warn( CharSequence content, Throwable error ); + + /** + * Send an exception to the user in the <b>warn</b> error level. + * <br/> + * The stack trace for this exception will be output when this error level is enabled. + * + * @param error + */ + void warn( Throwable error ); + + /** + * @return true if the <b>error</b> error level is enabled + */ + boolean isErrorEnabled(); + + /** + * Send a message to the user in the <b>error</b> error level. + * + * @param content + */ + void error( CharSequence content ); + + /** + * Send a message (and accompanying exception) to the user in the <b>error</b> error level. + * <br/> + * The error's stacktrace will be output when this error level is enabled. + * + * @param content + * @param error + */ + void error( CharSequence content, Throwable error ); + + /** + * Send an exception to the user in the <b>error</b> error level. + * <br/> + * The stack trace for this exception will be output when this error level is enabled. + * + * @param error + */ + void error( Throwable error ); +}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java b/framework/src/maven/apache-maven-3.3.3/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java new file mode 100644 index 00000000..90475bf5 --- /dev/null +++ b/framework/src/maven/apache-maven-3.3.3/maven-plugin-api/src/main/java/org/apache/maven/plugin/logging/SystemStreamLog.java @@ -0,0 +1,196 @@ +package org.apache.maven.plugin.logging; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * Logger with "standard" output and error output stream. + * + * @author jdcasey + */ +public class SystemStreamLog + implements Log +{ + /** + * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence) + */ + public void debug( CharSequence content ) + { + print( "debug", content ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence, java.lang.Throwable) + */ + public void debug( CharSequence content, Throwable error ) + { + print( "debug", content, error ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable) + */ + public void debug( Throwable error ) + { + print( "debug", error ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence) + */ + public void info( CharSequence content ) + { + print( "info", content ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence, java.lang.Throwable) + */ + public void info( CharSequence content, Throwable error ) + { + print( "info", content, error ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable) + */ + public void info( Throwable error ) + { + print( "info", error ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence) + */ + public void warn( CharSequence content ) + { + print( "warn", content ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence, java.lang.Throwable) + */ + public void warn( CharSequence content, Throwable error ) + { + print( "warn", content, error ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable) + */ + public void warn( Throwable error ) + { + print( "warn", error ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence) + */ + public void error( CharSequence content ) + { + System.err.println( "[error] " + content.toString() ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence, java.lang.Throwable) + */ + public void error( CharSequence content, Throwable error ) + { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter( sWriter ); + + error.printStackTrace( pWriter ); + + System.err.println( "[error] " + content.toString() + "\n\n" + sWriter.toString() ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable) + */ + public void error( Throwable error ) + { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter( sWriter ); + + error.printStackTrace( pWriter ); + + System.err.println( "[error] " + sWriter.toString() ); + } + + /** + * @see org.apache.maven.plugin.logging.Log#isDebugEnabled() + */ + public boolean isDebugEnabled() + { + // TODO: Not sure how best to set these for this implementation... + return false; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isInfoEnabled() + */ + public boolean isInfoEnabled() + { + return true; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isWarnEnabled() + */ + public boolean isWarnEnabled() + { + return true; + } + + /** + * @see org.apache.maven.plugin.logging.Log#isErrorEnabled() + */ + public boolean isErrorEnabled() + { + return true; + } + + private void print( String prefix, CharSequence content ) + { + System.out.println( "[" + prefix + "] " + content.toString() ); + } + + private void print( String prefix, Throwable error ) + { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter( sWriter ); + + error.printStackTrace( pWriter ); + + System.out.println( "[" + prefix + "] " + sWriter.toString() ); + } + + private void print( String prefix, CharSequence content, Throwable error ) + { + StringWriter sWriter = new StringWriter(); + PrintWriter pWriter = new PrintWriter( sWriter ); + + error.printStackTrace( pWriter ); + + System.out.println( "[" + prefix + "] " + content.toString() + "\n\n" + sWriter.toString() ); + } +}
\ No newline at end of file |