2929import org .slf4j .Marker ;
3030import org .slf4j .event .Level ;
3131
32- /**
33- * {@link LambdaLogger}'s configuration.
34- * <p>
35- * The configuration is similar to <a
36- * href="https://www.slf4j.org/api/org/slf4j/simple/SimpleLogger.html">SLF4J Simple</a>.
37- * <p>
38- * It looks for the {@code lambda-logger.properties} resource and read properties:
39- * <ul>
40- * <li><strong>dateTimeFormat</strong> - The date and time format to be used in the output messages.
41- * The pattern describing the date and time format is defined by {@link java.text.SimpleDateFormat}.
42- * If the format is not specified or is invalid, the number of milliseconds since start up
43- * will be output.</li>
44- * <li><strong>defaultLogLevel</strong> - Default log level for all instances of LambdaLogger.
45- * Must be one of (<em>trace</em>, <em>debug</em>, <em>info</em>, <em>warn</em>, <em>error</em>),
46- * a value is case-insensitive. If not specified, defaults to <em>info</em>.</li>
47- * <li><strong>levelInBrackets</strong> - Should the level string be output in brackets?
48- * Defaults to {@code false}.</li>
49- * <li><strong>requestId</strong> - Set the context name of <strong>AWS request ID</strong>.
50- * Defaults to {@code AWS_REQUEST_ID}.</li>
51- * <li><strong>showDateTime</strong> - Set to {@code true} if you want the current date and time
52- * to be included in output messages. Defaults to {@code false}.</li>
53- * <li><strong>showLogName</strong> - Set to {@code true} if you want the Logger instance name
54- * to be included in output messages. Defaults to {@code true}.</li>
55- * <li><strong>showShortLogName</strong> - Set to {@code true} if you want the last component of the name
56- * to be included in output messages. Defaults to {@code false}.</li>
57- * <li><strong>showThreadId</strong> - If you would like to output the current thread id,
58- * then set to {@code true}. Defaults to {@code false}.</li>
59- * <li><strong>showThreadName</strong> - Set to {@code true} if you want to output
60- * the current thread name. Defaults to {@code false}.</li>
61- * </ul>
62- * <p>
63- * The environment variables overrides the properties: <strong>LOG_AWS_REQUEST_ID</strong>,
64- * <strong>LOG_DATE_TIME_FORMAT</strong>, <strong>LOG_DEFAULT_LEVEL</strong>,
65- * <strong>LOG_LEVEL_IN_BRACKETS</strong>, <strong>LOG_SHOW_DATE_TIME</strong>,
66- * <strong>LOG_SHOW_NAME</strong>, <strong>LOG_SHOW_SHORT_NAME</strong>,
67- * <strong>LOG_SHOW_THREAD_ID</strong>, <strong>LOG_SHOW_THREAD_NAME</strong>.
68- */
6932class LoggerConfiguration {
7033
7134 private static final String DOT = "." ;
@@ -143,9 +106,6 @@ boolean showThreadName() {
143106 return showThreadName ;
144107 }
145108
146- /**
147- * {@link LambdaLogger} configuration's builder.
148- */
149109 static class Builder {
150110
151111 private DateFormat dateTimeFormat ;
@@ -162,58 +122,23 @@ static class Builder {
162122 private Builder () {
163123 }
164124
165- /**
166- * Build a LambdaLoggerConfiguration instance.
167- *
168- * @return a configuration instance
169- */
170125 LoggerConfiguration build () {
171126 requireNonNull (loggerPredicates , "Logger level is null" );
172127 requireNonNull (name , "Logger name is null" );
173128 requireNonNull (requestId , "AWS request ID is null" );
174129 return new LoggerConfiguration (this );
175130 }
176131
177- /**
178- * The date and time format to be used in the output messages.
179- * <p>
180- * The pattern describing the date and time format is defined by
181- * {@link java.text.SimpleDateFormat}. If the format is not specified or is invalid, the number
182- * of milliseconds since start up will be output.
183- *
184- * @param dateTimeFormat date and time format
185- * @return a builder
186- */
187132 Builder dateTimeFormat (@ Nullable DateFormat dateTimeFormat ) {
188133 this .dateTimeFormat = dateTimeFormat ;
189134 return this ;
190135 }
191136
192- /**
193- * Should the level string be output in brackets?
194- * <p>
195- * Defaults to {@code false}.
196- *
197- * @param levelInBrackets use brackets
198- * @return a builder
199- */
200137 Builder levelInBrackets (boolean levelInBrackets ) {
201138 this .levelInBrackets = levelInBrackets ;
202139 return this ;
203140 }
204141
205- /**
206- * The log level of the Logger instance.
207- * <p>
208- * Must be one of (<em>trace</em>, <em>debug</em>, <em>info</em>, <em>warn</em>,
209- * <em>error</em>), a value is case-insensitive. If not specified, defaults to <em>info</em>.
210- * <p>
211- * You can add some different log levels: it does not overwrite previous levels but add new one
212- * to a list. There has to be at least one log level.
213- *
214- * @param loggerLevel log level
215- * @return a builder
216- */
217142 Builder loggerLevel (@ NotNull Level loggerLevel ) {
218143 if (isNull (loggerPredicates )) {
219144 loggerPredicates = new ArrayList <>();
@@ -222,19 +147,6 @@ Builder loggerLevel(@NotNull Level loggerLevel) {
222147 return this ;
223148 }
224149
225- /**
226- * The marked log level of the Logger instance.
227- * <p>
228- * Must be one of (<em>trace</em>, <em>debug</em>, <em>info</em>, <em>warn</em>,
229- * <em>error</em>), a value is case-insensitive. If not specified, defaults to <em>info</em>.
230- * <p>
231- * You can add some different log levels: it does not overwrite previous levels but add new one
232- * to a list. There has to be at least one log level.
233- *
234- * @param loggerLevel default log level
235- * @param loggerMarkers markers
236- * @return a builder
237- */
238150 Builder loggerLevel (@ NotNull Level loggerLevel , @ NotNull Marker ... loggerMarkers ) {
239151 if (isNull (loggerPredicates )) {
240152 loggerPredicates = new ArrayList <>();
@@ -253,89 +165,36 @@ Builder loggerLevel(@NotNull Level loggerLevel, @NotNull Marker... loggerMarkers
253165 return this ;
254166 }
255167
256- /**
257- * Name of the Logger instance.
258- *
259- * @param name logger name
260- * @return a builder
261- */
262168 Builder name (@ NotNull String name ) {
263169 this .name = name ;
264170 return this ;
265171 }
266172
267- /**
268- * Context name of AWS request ID.
269- *
270- * @param requestId context name of AWS request ID
271- * @return a builder
272- */
273173 Builder requestId (@ NotNull String requestId ) {
274174 this .requestId = requestId ;
275175 return this ;
276176 }
277177
278- /**
279- * Set to {@code true} if you want the current date and time to be included in output messages.
280- * <p>
281- * Defaults to {@code false}.
282- *
283- * @param showDateTime show date and time
284- * @return a builder
285- */
286178 Builder showDateTime (boolean showDateTime ) {
287179 this .showDateTime = showDateTime ;
288180 return this ;
289181 }
290182
291- /**
292- * Set to {@code true} if you want the Logger instance name to be included in output messages.
293- * <p>
294- * Defaults to {@code true}.
295- *
296- * @param showLogName show log name
297- * @return a builder
298- */
299183 Builder showLogName (boolean showLogName ) {
300184 this .showLogName = showLogName ;
301185 return this ;
302186 }
303187
304- /**
305- * Set to {@code true} if you want the last component of the name to be included in output
306- * messages.
307- * <p>
308- * Defaults to {@code false}.
309- *
310- * @param showShortLogName show short log name
311- * @return a builder
312- */
313188 Builder showShortLogName (boolean showShortLogName ) {
314189 this .showShortLogName = showShortLogName ;
315190 return this ;
316191 }
317192
318- /**
319- * If you would like to output the current thread id, then set to {@code true}.
320- * <p>
321- * Defaults to {@code false}.
322- *
323- * @param showThreadId show the current thread ID
324- * @return a builder
325- */
326193 Builder showThreadId (boolean showThreadId ) {
327194 this .showThreadId = showThreadId ;
328195 return this ;
329196 }
330197
331- /**
332- * Set to {@code true} if you want to output the current thread name.
333- * <p>
334- * Defaults to {@code false}.
335- *
336- * @param showThreadName show the current thread name
337- * @return a builder
338- */
339198 Builder showThreadName (boolean showThreadName ) {
340199 this .showThreadName = showThreadName ;
341200 return this ;
0 commit comments