Java源码示例:net.java.sip.communicator.util.Logger

示例1
/**
 * Calls <tt>Thread.setUncaughtExceptionHandler()</tt>
 *
 * @param context The execution context of the bundle being started
 * (unused).
 * @throws Exception If this method throws an exception, this bundle is
 *   marked as stopped and the Framework will remove this bundle's
 *   listeners, unregister all services registered by this bundle, and
 *   release all services used by this bundle.
 */
public void start(BundleContext context)
    throws Exception
{
    logger.info("DNS service ... [STARTING]");
    bundleContext = context;
    context.addServiceListener(this);

    if(Logger.getLogger("org.xbill").isTraceEnabled())
        Options.set("verbose", "1");

    Lookup.setPacketLogger(new DnsJavaLogger());

    if(loadDNSProxyForward())
    {
        // dns is forced to go through a proxy so skip any further settings
        return;
    }

    if(UtilActivator.getConfigurationService().getBoolean(
            DnsUtilActivator.PNAME_BACKUP_RESOLVER_ENABLED,
            DnsUtilActivator.PDEFAULT_BACKUP_RESOLVER_ENABLED)
        && !getConfigurationService().getBoolean(
            CustomResolver.PNAME_DNSSEC_RESOLVER_ENABLED,
            CustomResolver.PDEFAULT_DNSSEC_RESOLVER_ENABLED))
    {
        bundleContext.registerService(
            CustomResolver.class.getName(),
            new ParallelResolverImpl(),
            null);
        logger.info("ParallelResolver ... [REGISTERED]");
    }

    if(getConfigurationService().getBoolean(
        CustomResolver.PNAME_DNSSEC_RESOLVER_ENABLED,
        CustomResolver.PDEFAULT_DNSSEC_RESOLVER_ENABLED))
    {
        bundleContext.registerService(
            CustomResolver.class.getName(),
            new ConfigurableDnssecResolver(new ExtendedResolver()),
            null);
        logger.info("DnssecResolver ... [REGISTERED]");
    }

    logger.info("DNS service ... [STARTED]");
}
 
示例2
/**
 * Logs a specific message and associated <tt>Throwable</tt> cause as an
 * error using the current <tt>Logger</tt> and then throws a new
 * <tt>OperationFailedException</tt> with the message, a specific error code
 * and the cause.
 *
 * @param message the message to be logged and then wrapped in a new
 * <tt>OperationFailedException</tt>
 * @param errorCode the error code to be assigned to the new
 * <tt>OperationFailedException</tt>
 * @param cause the <tt>Throwable</tt> that has caused the necessity to log
 * an error and have a new <tt>OperationFailedException</tt> thrown
 * @param logger the logger that we'd like to log the error <tt>message</tt>
 * and <tt>cause</tt>.
 *
 * @throws OperationFailedException the exception that we wanted this method
 * to throw.
 */
public static void throwOperationFailedException( String    message,
                                                  int       errorCode,
                                                  Throwable cause,
                                                  Logger    logger)
    throws OperationFailedException
{
    logger.error(message, cause);

    if(cause == null)
        throw new OperationFailedException(message, errorCode);
    else
        throw new OperationFailedException(message, errorCode, cause);
}
 
示例3
/**
 * Logs a specific message and associated <tt>Throwable</tt> cause as an
 * error using the current <tt>Logger</tt> and then throws a new
 * <tt>OperationFailedException</tt> with the message, a specific error code
 * and the cause.
 *
 * @param message the message to be logged and then wrapped in a new
 * <tt>OperationFailedException</tt>
 * @param errorCode the error code to be assigned to the new
 * <tt>OperationFailedException</tt>
 * @param cause the <tt>Throwable</tt> that has caused the necessity to log
 * an error and have a new <tt>OperationFailedException</tt> thrown
 * @param logger the logger that we'd like to log the error <tt>message</tt>
 * and <tt>cause</tt>.
 *
 * @throws OperationFailedException the exception that we wanted this method
 * to throw.
 */
public static void throwOperationFailedException( String    message,
                                                  int       errorCode,
                                                  Throwable cause,
                                                  Logger    logger)
    throws OperationFailedException
{
    logger.error(message, cause);

    if(cause == null)
        throw new OperationFailedException(message, errorCode);
    else
        throw new OperationFailedException(message, errorCode, cause);
}