001    /*
002     * Copyright (c) OSGi Alliance (2000, 2008). All Rights Reserved.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.osgi.service.log;
017    
018    import org.osgi.framework.Bundle;
019    import org.osgi.framework.ServiceReference;
020    
021    /**
022     * Provides methods to access the information contained in an individual Log
023     * Service log entry.
024     * 
025     * <p>
026     * A <code>LogEntry</code> object may be acquired from the
027     * <code>LogReaderService.getLog</code> method or by registering a
028     * <code>LogListener</code> object.
029     * 
030     * @ThreadSafe
031     * @version $Revision: 5654 $
032     * @see LogReaderService#getLog
033     * @see LogListener
034     */
035    public interface LogEntry {
036            /**
037             * Returns the bundle that created this <code>LogEntry</code> object.
038             * 
039             * @return The bundle that created this <code>LogEntry</code> object;
040             *         <code>null</code> if no bundle is associated with this
041             *         <code>LogEntry</code> object.
042             */
043            public Bundle getBundle();
044    
045            /**
046             * Returns the <code>ServiceReference</code> object for the service associated
047             * with this <code>LogEntry</code> object.
048             * 
049             * @return <code>ServiceReference</code> object for the service associated
050             *         with this <code>LogEntry</code> object; <code>null</code> if no
051             *         <code>ServiceReference</code> object was provided.
052             */
053            public ServiceReference getServiceReference();
054    
055            /**
056             * Returns the severity level of this <code>LogEntry</code> object.
057             * 
058             * <p>
059             * This is one of the severity levels defined by the <code>LogService</code>
060             * interface.
061             * 
062             * @return Severity level of this <code>LogEntry</code> object.
063             * 
064             * @see LogService#LOG_ERROR
065             * @see LogService#LOG_WARNING
066             * @see LogService#LOG_INFO
067             * @see LogService#LOG_DEBUG
068             */
069            public int getLevel();
070    
071            /**
072             * Returns the human readable message associated with this <code>LogEntry</code>
073             * object.
074             * 
075             * @return <code>String</code> containing the message associated with this
076             *         <code>LogEntry</code> object.
077             */
078            public String getMessage();
079    
080            /**
081             * Returns the exception object associated with this <code>LogEntry</code>
082             * object.
083             * 
084             * <p>
085             * In some implementations, the returned exception may not be the original
086             * exception. To avoid references to a bundle defined exception class, thus
087             * preventing an uninstalled bundle from being garbage collected, the Log
088             * Service may return an exception object of an implementation defined
089             * Throwable subclass. The returned object will attempt to provide as much
090             * information as possible from the original exception object such as the
091             * message and stack trace.
092             * 
093             * @return <code>Throwable</code> object of the exception associated with this
094             *         <code>LogEntry</code>;<code>null</code> if no exception is
095             *         associated with this <code>LogEntry</code> object.
096             */
097            public Throwable getException();
098    
099            /**
100             * Returns the value of <code>currentTimeMillis()</code> at the time this
101             * <code>LogEntry</code> object was created.
102             * 
103             * @return The system time in milliseconds when this <code>LogEntry</code>
104             *         object was created.
105             * @see "System.currentTimeMillis()"
106             */
107            public long getTime();
108    }