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.rat.utils;
20
21 /**
22 * The definition of logging for the core. UIs are expected to provide an implementation of
23 * Log to log data to the appropriate system within the UI.
24 */
25 public interface Log {
26 /**
27 * The log levels supported by logging.
28 */
29 public enum Level {
30 // these must be listed in order of decreasing noisiness.
31 /**
32 * Log debug only.
33 */
34 DEBUG,
35 /**
36 * Log info only.
37 */
38 INFO,
39 /**
40 * Log warn only.
41 */
42 WARN,
43 /**
44 * Log error only.
45 */
46 ERROR,
47 /**
48 * Log nothing.
49 */
50 OFF};
51
52 /**
53 * Writes a message at a specific log level.
54 * @param level The log level to write at.
55 * @param message the Message to write.
56 */
57 void log(Level level, String message);
58
59 default void log(Level level, Object message) {
60 log(level, message == null ? "NULL" : message.toString());
61 }
62
63 default void debug(Object message) {
64 log(Level.DEBUG, message);
65 }
66
67 default void info(Object message) {
68 log(Level.INFO, message);
69 }
70
71 default void warn(Object message) {
72 log(Level.WARN, message);
73 }
74
75 default void error(Object message) {
76 log(Level.ERROR, message);
77 }
78 }