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