View Javadoc
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.maven.api.plugin;
20  
21  import java.util.function.Supplier;
22  
23  import org.apache.maven.api.annotations.Experimental;
24  import org.apache.maven.api.annotations.Provider;
25  
26  /**
27   * This interface supplies the API for providing feedback to the user from the {@code Mojo},
28   * using standard Maven channels.
29   * There should be no big surprises here, although you may notice that the methods accept
30   * <code>java.lang.CharSequence</code> rather than <code>java.lang.String</code>. This is provided mainly as a
31   * convenience, to enable developers to pass things like <code>java.lang.StringBuffer</code> directly into the logger,
32   * rather than formatting first by calling <code>toString()</code>.
33   *
34   * @since 4.0.0
35   */
36  @Experimental
37  @Provider
38  public interface Log {
39      /**
40       * {@return true if the <b>debug</b> error level is enabled}.
41       */
42      boolean isDebugEnabled();
43  
44      /**
45       * Sends a message to the user in the <b>debug</b> error level.
46       *
47       * @param content the message to log
48       */
49      void debug(CharSequence content);
50  
51      /**
52       * Sends a message (and accompanying exception) to the user in the <b>debug</b> error level.
53       * The error's stacktrace will be output when this error level is enabled.
54       *
55       * @param content the message to log
56       * @param error the error that caused this log
57       */
58      void debug(CharSequence content, Throwable error);
59  
60      /**
61       * Sends an exception to the user in the <b>debug</b> error level.
62       * The stack trace for this exception will be output when this error level is enabled.
63       *
64       * @param error the error that caused this log
65       */
66      void debug(Throwable error);
67  
68      void debug(Supplier<String> content);
69  
70      void debug(Supplier<String> content, Throwable error);
71  
72      /**
73       * {@return true if the <b>info</b> error level is enabled}.
74       */
75      boolean isInfoEnabled();
76  
77      /**
78       * Sends a message to the user in the <b>info</b> error level.
79       *
80       * @param content the message to log
81       */
82      void info(CharSequence content);
83  
84      /**
85       * Sends a message (and accompanying exception) to the user in the <b>info</b> error level.
86       * The error's stacktrace will be output when this error level is enabled.
87       *
88       * @param content the message to log
89       * @param error the error that caused this log
90       */
91      void info(CharSequence content, Throwable error);
92  
93      /**
94       * Sends an exception to the user in the <b>info</b> error level.
95       * The stack trace for this exception will be output when this error level is enabled.
96       *
97       * @param error the error that caused this log
98       */
99      void info(Throwable error);
100 
101     void info(Supplier<String> content);
102 
103     void info(Supplier<String> content, Throwable error);
104 
105     /**
106      * {@return true if the <b>warn</b> error level is enabled}.
107      */
108     boolean isWarnEnabled();
109 
110     /**
111      * Sends a message to the user in the <b>warn</b> error level.
112      *
113      * @param content the message to log
114      */
115     void warn(CharSequence content);
116 
117     /**
118      * Sends a message (and accompanying exception) to the user in the <b>warn</b> error level.
119      * The error's stacktrace will be output when this error level is enabled.
120      *
121      * @param content the message to log
122      * @param error the error that caused this log
123      */
124     void warn(CharSequence content, Throwable error);
125 
126     /**
127      * Sends an exception to the user in the <b>warn</b> error level.
128      * The stack trace for this exception will be output when this error level is enabled.
129      *
130      * @param error the error that caused this log
131      */
132     void warn(Throwable error);
133 
134     void warn(Supplier<String> content);
135 
136     void warn(Supplier<String> content, Throwable error);
137 
138     /**
139      * {@return true if the <b>error</b> error level is enabled}.
140      */
141     boolean isErrorEnabled();
142 
143     /**
144      * Sends a message to the user in the <b>error</b> error level.
145      *
146      * @param content the message to log
147      */
148     void error(CharSequence content);
149 
150     /**
151      * Sends a message (and accompanying exception) to the user in the <b>error</b> error level.
152      * The error's stacktrace will be output when this error level is enabled.
153      *
154      * @param content the message to log
155      * @param error the error that caused this log
156      */
157     void error(CharSequence content, Throwable error);
158 
159     /**
160      * Sends an exception to the user in the <b>error</b> error level.
161      * The stack trace for this exception will be output when this error level is enabled.
162      *
163      * @param error the error that caused this log
164      */
165     void error(Throwable error);
166 
167     void error(Supplier<String> content);
168 
169     void error(Supplier<String> content, Throwable error);
170 }