/* * $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 $ * * Copyright (c) OSGi Alliance (2000, 2006). All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.osgi.service.log; import org.osgi.framework.ServiceReference; /** * Provides methods for bundles to write messages to the log. * *
* LogService methods are provided to log messages; optionally with a
* ServiceReference object or an exception.
*
*
* Bundles must log messages in the OSGi environment with a severity level * according to the following hierarchy: *
* This log entry indicates the bundle or service may not be functional. */ public static final int LOG_ERROR = 1; /** * A warning message (Value 2). * *
* This log entry indicates a bundle or service is still functioning but may * experience problems in the future because of the warning condition. */ public static final int LOG_WARNING = 2; /** * An informational message (Value 3). * *
* This log entry may be the result of any change in the bundle or service * and does not indicate a problem. */ public static final int LOG_INFO = 3; /** * A debugging message (Value 4). * *
* This log entry is used for problem determination and may be irrelevant to * anyone but the bundle developer. */ public static final int LOG_DEBUG = 4; /** * Logs a message. * *
* The ServiceReference field and the Throwable field
* of the LogEntry object will be set to null.
*
* @param level The severity of the message. This should be one of the
* defined log levels but may be any integer that is interpreted in a
* user defined way.
* @param message Human readable string describing the condition or
* null.
* @see #LOG_ERROR
* @see #LOG_WARNING
* @see #LOG_INFO
* @see #LOG_DEBUG
*/
public void log(int level, String message);
/**
* Logs a message with an exception.
*
*
* The ServiceReference field of the LogEntry object
* will be set to null.
*
* @param level The severity of the message. This should be one of the
* defined log levels but may be any integer that is interpreted in a
* user defined way.
* @param message The human readable string describing the condition or
* null.
* @param exception The exception that reflects the condition or
* null.
* @see #LOG_ERROR
* @see #LOG_WARNING
* @see #LOG_INFO
* @see #LOG_DEBUG
*/
public void log(int level, String message, Throwable exception);
/**
* Logs a message associated with a specific ServiceReference
* object.
*
*
* The Throwable field of the LogEntry will be set to
* null.
*
* @param sr The ServiceReference object of the service that this
* message is associated with or null.
* @param level The severity of the message. This should be one of the
* defined log levels but may be any integer that is interpreted in a
* user defined way.
* @param message Human readable string describing the condition or
* null.
* @see #LOG_ERROR
* @see #LOG_WARNING
* @see #LOG_INFO
* @see #LOG_DEBUG
*/
public void log(ServiceReference sr, int level, String message);
/**
* Logs a message with an exception associated and a
* ServiceReference object.
*
* @param sr The ServiceReference object of the service that this
* message is associated with.
* @param level The severity of the message. This should be one of the
* defined log levels but may be any integer that is interpreted in a
* user defined way.
* @param message Human readable string describing the condition or
* null.
* @param exception The exception that reflects the condition or
* null.
* @see #LOG_ERROR
* @see #LOG_WARNING
* @see #LOG_INFO
* @see #LOG_DEBUG
*/
public void log(ServiceReference sr, int level, String message,
Throwable exception);
}