org.apache.felix.ipojo.util
Class Logger

java.lang.Object
  extended by org.apache.felix.ipojo.util.Logger

public class Logger
extends java.lang.Object

iPOJO Logger. This class is an helper class implementing a simple log system. This logger sends log messages to a log service if available.

Author:
Felix Project Team

Field Summary
static int DEBUG
          The Log Level DEBUG.
static int ERROR
          The Log Level ERROR.
static int INFO
          The Log Level INFO.
static java.lang.String IPOJO_LOG_LEVEL_HEADER
          iPOJO log level manifest header.
static java.lang.String IPOJO_LOG_LEVEL_PROP
          The iPOJO default log level property.
private  org.osgi.framework.BundleContext m_context
          The Bundle Context used to get the log service.
private  int m_level
          The trace level of this logger.
private  java.lang.String m_name
          The name of the logger.
static int WARNING
          The Log Level WARNING.
 
Constructor Summary
Logger(org.osgi.framework.BundleContext context, java.lang.String name)
          Create a logger.
Logger(org.osgi.framework.BundleContext context, java.lang.String name, int level)
          Creates a logger.
 
Method Summary
private  void dispatch(int level, java.lang.String msg)
          Internal log method.
private  void dispatch(int level, java.lang.String msg, java.lang.Throwable exception)
          Internal log method.
private static int getDefaultLevel(org.osgi.framework.BundleContext context)
          Gets the default logger level.
 void log(int level, java.lang.String msg)
          Logs a message.
 void log(int level, java.lang.String msg, java.lang.Throwable exception)
          Logs a message with an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IPOJO_LOG_LEVEL_PROP

public static final java.lang.String IPOJO_LOG_LEVEL_PROP
The iPOJO default log level property.

See Also:
Constant Field Values

IPOJO_LOG_LEVEL_HEADER

public static final java.lang.String IPOJO_LOG_LEVEL_HEADER
iPOJO log level manifest header. Use an upper case to support bnd.

See Also:
Constant Field Values

ERROR

public static final int ERROR
The Log Level ERROR.

See Also:
Constant Field Values

WARNING

public static final int WARNING
The Log Level WARNING.

See Also:
Constant Field Values

INFO

public static final int INFO
The Log Level INFO.

See Also:
Constant Field Values

DEBUG

public static final int DEBUG
The Log Level DEBUG.

See Also:
Constant Field Values

m_context

private org.osgi.framework.BundleContext m_context
The Bundle Context used to get the log service.


m_name

private java.lang.String m_name
The name of the logger.


m_level

private int m_level
The trace level of this logger.

Constructor Detail

Logger

public Logger(org.osgi.framework.BundleContext context,
              java.lang.String name,
              int level)
Creates a logger.

Parameters:
context - the bundle context
name - the name of the logger
level - the trace level

Logger

public Logger(org.osgi.framework.BundleContext context,
              java.lang.String name)
Create a logger. Uses the default logger level.

Parameters:
context - the bundle context
name - the name of the logger
Method Detail

log

public void log(int level,
                java.lang.String msg)
Logs a message.

Parameters:
level - the level of the message
msg - the the message to log

log

public void log(int level,
                java.lang.String msg,
                java.lang.Throwable exception)
Logs a message with an exception.

Parameters:
level - the level of the message
msg - the message to log
exception - the exception attached to the message

dispatch

private void dispatch(int level,
                      java.lang.String msg)
Internal log method.

Parameters:
level - the level of the message.
msg - the message to log

dispatch

private void dispatch(int level,
                      java.lang.String msg,
                      java.lang.Throwable exception)
Internal log method.

Parameters:
level - the level of the message.
msg - the message to log
exception - the exception attached to the message

getDefaultLevel

private static int getDefaultLevel(org.osgi.framework.BundleContext context)
Gets the default logger level. The property is searched inside the framework properties, the system properties, and in the manifest from the given bundle context. By default, set the level to WARNING.

Parameters:
context - the bundle context.
Returns:
the default log level.


Copyright © 2006-2010 The Apache Software Foundation. All Rights Reserved.