KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > osgi > service > log > LogService


1 /*
2  * $Header: /cvshome/build/org.osgi.service.log/src/org/osgi/service/log/LogService.java,v 1.9 2006/06/16 16:31:49 hargrave Exp $
3  *
4  * Copyright (c) OSGi Alliance (2000, 2006). All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * 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, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.osgi.service.log;
19
20 import org.osgi.framework.ServiceReference;
21
22 /**
23  * Provides methods for bundles to write messages to the log.
24  *
25  * <p>
26  * <code>LogService</code> methods are provided to log messages; optionally with a
27  * <code>ServiceReference</code> object or an exception.
28  *
29  * <p>
30  * Bundles must log messages in the OSGi environment with a severity level
31  * according to the following hierarchy:
32  * <ol>
33  * <li>{@link #LOG_ERROR}
34  * <li>{@link #LOG_WARNING}
35  * <li>{@link #LOG_INFO}
36  * <li>{@link #LOG_DEBUG}
37  * </ol>
38  *
39  * @version $Revision: 1.9 $
40  */

41 public interface LogService {
42     /**
43      * An error message (Value 1).
44      *
45      * <p>
46      * This log entry indicates the bundle or service may not be functional.
47      */

48     public static final int LOG_ERROR = 1;
49     /**
50      * A warning message (Value 2).
51      *
52      * <p>
53      * This log entry indicates a bundle or service is still functioning but may
54      * experience problems in the future because of the warning condition.
55      */

56     public static final int LOG_WARNING = 2;
57     /**
58      * An informational message (Value 3).
59      *
60      * <p>
61      * This log entry may be the result of any change in the bundle or service
62      * and does not indicate a problem.
63      */

64     public static final int LOG_INFO = 3;
65     /**
66      * A debugging message (Value 4).
67      *
68      * <p>
69      * This log entry is used for problem determination and may be irrelevant to
70      * anyone but the bundle developer.
71      */

72     public static final int LOG_DEBUG = 4;
73
74     /**
75      * Logs a message.
76      *
77      * <p>
78      * The <code>ServiceReference</code> field and the <code>Throwable</code> field
79      * of the <code>LogEntry</code> object will be set to <code>null</code>.
80      *
81      * @param level The severity of the message. This should be one of the
82      * defined log levels but may be any integer that is interpreted in a
83      * user defined way.
84      * @param message Human readable string describing the condition or
85      * <code>null</code>.
86      * @see #LOG_ERROR
87      * @see #LOG_WARNING
88      * @see #LOG_INFO
89      * @see #LOG_DEBUG
90      */

91     public void log(int level, String JavaDoc message);
92
93     /**
94      * Logs a message with an exception.
95      *
96      * <p>
97      * The <code>ServiceReference</code> field of the <code>LogEntry</code> object
98      * will be set to <code>null</code>.
99      *
100      * @param level The severity of the message. This should be one of the
101      * defined log levels but may be any integer that is interpreted in a
102      * user defined way.
103      * @param message The human readable string describing the condition or
104      * <code>null</code>.
105      * @param exception The exception that reflects the condition or
106      * <code>null</code>.
107      * @see #LOG_ERROR
108      * @see #LOG_WARNING
109      * @see #LOG_INFO
110      * @see #LOG_DEBUG
111      */

112     public void log(int level, String JavaDoc message, Throwable JavaDoc exception);
113
114     /**
115      * Logs a message associated with a specific <code>ServiceReference</code>
116      * object.
117      *
118      * <p>
119      * The <code>Throwable</code> field of the <code>LogEntry</code> will be set to
120      * <code>null</code>.
121      *
122      * @param sr The <code>ServiceReference</code> object of the service that this
123      * message is associated with or <code>null</code>.
124      * @param level The severity of the message. This should be one of the
125      * defined log levels but may be any integer that is interpreted in a
126      * user defined way.
127      * @param message Human readable string describing the condition or
128      * <code>null</code>.
129      * @see #LOG_ERROR
130      * @see #LOG_WARNING
131      * @see #LOG_INFO
132      * @see #LOG_DEBUG
133      */

134     public void log(ServiceReference sr, int level, String JavaDoc message);
135
136     /**
137      * Logs a message with an exception associated and a
138      * <code>ServiceReference</code> object.
139      *
140      * @param sr The <code>ServiceReference</code> object of the service that this
141      * message is associated with.
142      * @param level The severity of the message. This should be one of the
143      * defined log levels but may be any integer that is interpreted in a
144      * user defined way.
145      * @param message Human readable string describing the condition or
146      * <code>null</code>.
147      * @param exception The exception that reflects the condition or
148      * <code>null</code>.
149      * @see #LOG_ERROR
150      * @see #LOG_WARNING
151      * @see #LOG_INFO
152      * @see #LOG_DEBUG
153      */

154     public void log(ServiceReference sr, int level, String JavaDoc message,
155             Throwable JavaDoc exception);
156 }
157
Popular Tags