1 /*-
2 * #%L
3 * prolobjectlink-jpi
4 * %%
5 * Copyright (C) 2012 - 2019 Prolobjectlink Project
6 * %%
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 * #L%
25 */
26 package io.github.prolobjectlink.prolog;
27
28 import java.util.logging.Level;
29 import java.util.logging.Logger;
30
31 /**
32 * Logger platform interface to log message at any level. Is an adapter for
33 * {@link Logger} adapting the Java logger mechanism for use with the most
34 * popular logger methods. This logger mechanism is accessible from
35 * {@link PrologProvider#getLogger()} or {@link PrologEngine#getLogger()} This
36 * logger interface have all traditional methods used to log messages at
37 * different levels (trace, debug, info,warn,error).
38 *
39 * The levels used for this logger interface are {@link Level} constants present
40 * in the table.
41 *
42 * <table BORDER > <caption>Level table</caption>
43 * <tr>
44 * <td ALIGN=CENTER><b>Method</b></td>
45 * <td ALIGN=CENTER><b>Level</b></td>
46 * </tr>
47 * <tr>
48 * <td>{@link #trace(Object, Object, Throwable)}</td>
49 * <td>{@link Level#FINEST}</td>
50 * </tr>
51 * <tr>
52 * <td>{@link #debug(Object, Object, Throwable)}</td>
53 * <td>{@link Level#FINE}</td>
54 * </tr>
55 * <tr>
56 * <td>{@link #info(Object, Object, Throwable)}</td>
57 * <td>{@link Level#INFO}</td>
58 * </tr>
59 * <tr>
60 * <td>{@link #warn(Object, Object, Throwable)}</td>
61 * <td>{@link Level#WARNING}</td>
62 * </tr>
63 * <tr>
64 * <td>{@link #error(Object, Object, Throwable)}</td>
65 * <td>{@link Level#SEVERE}</td>
66 * </tr>
67 * </table>
68 *
69 * By default the platform implement a logger mechanism for drop log messages in
70 * Operating System temporal directory into files named
71 * prolobjectlink-YYYY.MM.DD.
72 *
73 * In {@link AbstractLogger} class there are many implementations for this
74 * interface. Every final implementation class can extends from
75 * {@link AbstractLogger}.
76 *
77 * @author Jose Zalacain
78 * @since 1.0
79 */
80 public interface PrologLogger {
81
82 public static final String RUNTIME_ERROR = "Runtime error ";
83
84 public static final String FILE_NOT_FOUND = "File not found ";
85
86 public static final String CLASS_NOT_FOUND = "Class not found ";
87
88 public static final String UNKNOWN_PREDICATE = "Unknow predicate";
89
90 public static final String SYNTAX_ERROR = "Syntax error in the file ";
91
92 public static final String NON_SOLUTION = "The query no have solution ";
93
94 public static final String INDICATOR_NOT_FOUND = "Predicate not found for";
95
96 public static final String IO = "Some error occurs opening the file";
97
98 public static final String ERROR_LOADING_BUILT_INS = "Error loading prolog built-ins ";
99
100 public static final String DONT_WORRY = "Don't worry about it, the file was create for you ";
101
102 public static final String INTERRUPTED_ERROR = "Thread interrupted error";
103
104 public static final String EXECUTION_ERROR = "Thread execution error";
105
106 public static final String FILE_NOT_DELETE = "File not delete ";
107
108 public static final String INSTANTIATION = "Instantiation error ";
109
110 public static final String ILLEGAL_ACCESS = "Illegal access error ";
111
112 public static final String NO_SUCH_METHOD = "No such method error";
113
114 public static final String SECURITY = "Security error ";
115
116 public static final String SQL_ERROR = "SQL error ";
117
118 public static final String UNKNOWN_HOST = "Unknow Host error";
119
120 public static final String ILLEGAL_ARGUMENT = "Illegal argument error";
121
122 public static final String INVOCATION_TARGET = "Invocation target error";
123
124 public static final String NO_SUCH_FIELD = "No such field error";
125
126 public static final String CLASS_CAST = "Class cast error";
127
128 public static final String URI = "URI Syntax error";
129
130 public static final String URL = "URL Syntax error";
131
132 public static final String LINK = "Link library error";
133
134 /**
135 * Log a message from a given object sender at the given level.
136 *
137 * @param sender object that invoke the logger service.
138 * @param level log level.
139 * @param message message to be logged.
140 * @since 1.0
141 */
142 public void log(Object sender, Level level, Object message);
143
144 /**
145 * Log a message from a given object sender at the given level. Append a
146 * {@link Throwable} argument used for log exceptions if is needed.
147 *
148 * @param sender object that invoke the logger service.
149 * @param level log level.
150 * @param message message to be logged.
151 * @param t argument used for log exceptions.
152 * @since 1.0
153 */
154 public void log(Object sender, Level level, Object message, Throwable t);
155
156 /**
157 * Log a message from a given object sender at {@link Level#FINEST} level. Is a
158 * shortcut to {@code log(sender, Level.FINEST, message);}
159 *
160 * @param sender object that invoke the logger service.
161 * @param message message to be logged.
162 * @since 1.0
163 */
164 public void trace(Object sender, Object message);
165
166 /**
167 * Log a message from a given object sender at {@link Level#FINEST} level.
168 * Append a {@link Throwable} argument used for log exceptions if is needed. Is
169 * a shortcut to {@code log(sender, Level.FINEST, message, t);}
170 *
171 * @param sender object that invoke the logger service.
172 * @param message message to be logged.
173 * @param t argument used for log exceptions.
174 * @since 1.0
175 */
176 public void trace(Object sender, Object message, Throwable t);
177
178 /**
179 * Log a message from a given object sender at {@link Level#FINE} level. Is a
180 * shortcut to {@code log(sender, Level.FINE, message);}
181 *
182 * @param sender object that invoke the logger service.
183 * @param message message to be logged.
184 * @since 1.0
185 */
186 public void debug(Object sender, Object message);
187
188 /**
189 * Log a message from a given object sender at {@link Level#FINE} level. Append
190 * a {@link Throwable} argument used for log exceptions if is needed. Is a
191 * shortcut to {@code log(sender, Level.FINE, message, t);}
192 *
193 *
194 * @param sender object that invoke the logger service.
195 * @param message message to be logged.
196 * @param t argument used for log exceptions.
197 * @since 1.0
198 */
199 public void debug(Object sender, Object message, Throwable t);
200
201 /**
202 * Log a message from a given object sender at {@link Level#INFO} level. Is a
203 * shortcut to {@code log(sender, Level.INFO, message);}
204 *
205 * @param sender object that invoke the logger service.
206 * @param message message to be logged.
207 * @since 1.0
208 */
209 public void info(Object sender, Object message);
210
211 /**
212 * Log a message from a given object sender at {@link Level#INFO} level. Append
213 * a {@link Throwable} argument used for log exceptions if is needed. Is a
214 * shortcut to {@code log(sender, Level.INFO, message, t);}
215 *
216 *
217 * @param sender object that invoke the logger service.
218 * @param message message to be logged.
219 * @param t argument used for log exceptions.
220 * @since 1.0
221 */
222 public void info(Object sender, Object message, Throwable t);
223
224 /**
225 * Log a message from a given object sender at {@link Level#WARNING} level. Is a
226 * shortcut to {@code log(sender, Level.WARNING, message);}
227 *
228 * @param sender object that invoke the logger service.
229 * @param message message to be logged.
230 * @since 1.0
231 */
232 public void warn(Object sender, Object message);
233
234 /**
235 * Log a message from a given object sender at {@link Level#WARNING} level.
236 * Append a {@link Throwable} argument used for log exceptions if is needed. Is
237 * a shortcut to {@code log(sender, Level.WARNING, message, t);}
238 *
239 *
240 * @param sender object that invoke the logger service.
241 * @param message message to be logged.
242 * @param t argument used for log exceptions.
243 * @since 1.0
244 */
245 public void warn(Object sender, Object message, Throwable t);
246
247 /**
248 * Log a message from a given object sender at {@link Level#SEVERE} level. Is a
249 * shortcut to {@code log(sender, Level.SEVERE, message);}
250 *
251 * @param sender object that invoke the logger service.
252 * @param message message to be logged.
253 * @since 1.0
254 */
255 public void error(Object sender, Object message);
256
257 /**
258 * Log a message from a given object sender at {@link Level#SEVERE} level.
259 * Append a {@link Throwable} argument used for log exceptions if is needed. Is
260 * a shortcut to {@code log(sender, Level.SEVERE, message, t);}
261 *
262 *
263 * @param sender object that invoke the logger service.
264 * @param message message to be logged.
265 * @param t argument used for log exceptions.
266 * @since 1.0
267 */
268 public void error(Object sender, Object message, Throwable t);
269
270 }