Mercurial > jhg
comparison src/org/tmatesoft/hg/util/LogFacility.java @ 456:909306e412e2
Refactor LogFacility and SessionContext, better API for both
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 18 Jun 2012 16:54:00 +0200 |
parents | 981f9f50bb6c |
children |
comparison
equal
deleted
inserted
replaced
454:36fd1fd06492 | 456:909306e412e2 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 TMate Software Ltd | 2 * Copyright (c) 2011-2012 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
14 * the terms of a license other than GNU General Public License | 14 * the terms of a license other than GNU General Public License |
15 * contact TMate Software at support@hg4j.com | 15 * contact TMate Software at support@hg4j.com |
16 */ | 16 */ |
17 package org.tmatesoft.hg.util; | 17 package org.tmatesoft.hg.util; |
18 | 18 |
19 import org.tmatesoft.hg.internal.Experimental; | |
20 | 19 |
21 /** | 20 /** |
22 * WORK IN PROGRESS | 21 * Facility to dump various messages. |
23 * | 22 * |
24 * Intention of this class is to abstract away almost any log facility out there clients might be using with the <b>Hg4J</b> library, | 23 * Intention of this class is to abstract away almost any log facility out there clients might be using with the <b>Hg4J</b> library, |
25 * not to be a full-fledged logging facility of its own. | 24 * not to be a full-fledged logging facility of its own. |
26 * | 25 * |
27 * Implementations may wrap platform- or application-specific loggers, e.g. {@link java.util.logging.Logger} or | 26 * Implementations may wrap platform- or application-specific loggers, e.g. {@link java.util.logging.Logger} or |
28 * <code>org.eclipse.core.runtime.ILog</code> | 27 * <code>org.eclipse.core.runtime.ILog</code> |
29 * | 28 * |
30 * @author Artem Tikhomirov | 29 * @author Artem Tikhomirov |
31 * @author TMate Software Ltd. | 30 * @author TMate Software Ltd. |
32 */ | 31 */ |
33 @Experimental(reason="API might get changed") | |
34 public interface LogFacility { | 32 public interface LogFacility { |
33 | |
34 public enum Severity { | |
35 Debug, Info, Warn, Error // order is important | |
36 } | |
35 | 37 |
38 /** | |
39 * Effective way to avoid attempts to construct debug dumps when they are of no interest. Basically, <code>getLevel() < Info</code> | |
40 * | |
41 * @return <code>true</code> if interested in debug dumps | |
42 */ | |
36 boolean isDebug(); | 43 boolean isDebug(); |
37 boolean isInfo(); | |
38 | 44 |
39 // src and format never null | 45 /** |
40 void debug(Class<?> src, String format, Object... args); | 46 * |
41 void info(Class<?> src, String format, Object... args); | 47 * @return lowest (from {@link Severity#Debug} to {@link Severity#Error} active severity level |
42 void warn(Class<?> src, String format, Object... args); | 48 */ |
43 void error(Class<?> src, String format, Object... args); | 49 Severity getLevel(); |
44 | 50 |
45 // src shall be non null, either th or message or both | 51 /** |
46 void debug(Class<?> src, Throwable th, String message); | 52 * Dump a message |
47 void info(Class<?> src, Throwable th, String message); | 53 * @param src identifies source of the message, never <code>null</code> |
48 void warn(Class<?> src, Throwable th, String message); | 54 * @param severity one of predefined levels |
49 void error(Class<?> src, Throwable th, String message); | 55 * @param format message format suitable for {@link String#format(String, Object...)}, never <code>null</code> |
56 * @param args optional arguments for the preceding format argument, may be <code>null</code> | |
57 */ | |
58 void dump(Class<?> src, Severity severity, String format, Object... args); | |
59 | |
60 /** | |
61 * Alternative to dump an exception | |
62 * | |
63 * @param src identifies source of the message, never <code>null</code> | |
64 * @param severity one of predefined levels | |
65 * @param th original exception, never <code>null</code> | |
66 * @param message additional description of the error/conditions, may be <code>null</code> | |
67 */ | |
68 void dump(Class<?> src, Severity severity, Throwable th, String message); | |
50 } | 69 } |