blob: 13c60c0a399a279d9bacc1df28f7b7a3148f2a98 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2019 Xored Software Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Xored Software Inc - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.rcptt.logging;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Q7LoggingPlugin extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.rcptt.logging"; //$NON-NLS-1$
// The shared instance
private static Q7LoggingPlugin plugin;
/**
* The constructor
*/
public Q7LoggingPlugin() {
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Q7LoggingPlugin getDefault() {
return plugin;
}
public static CoreException createException(String message, Throwable cause) {
return new CoreException(createStatus(message, IStatus.ERROR, cause));
}
private static IStatus createStatus(String message, int severity,
Throwable cause) {
return new Status(severity, PLUGIN_ID, message, cause);
}
public static void error(String message, Throwable cause) {
getDefault().getLog().log(createStatus(message, IStatus.ERROR, cause));
}
}