Skip to main content
summaryrefslogtreecommitdiffstats
blob: 10fc6efa7cc56f6f52bff1bb9bdc6b923ef77a67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*******************************************************************************
 * Copyright (c) 2009 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.make.xlc.core.activator;

import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;

/**
 * @author crecoskie
 *
 */
public class Activator extends Plugin {

	public static final String PLUGIN_ID = "org.eclipse.cdt.make.xlc.core"; //$NON-NLS-1$
	private static Activator fInstance;

	/**
	 * 
	 */
	public Activator() {
		super();
		if(fInstance == null) {
			fInstance = this;
		}
	}
	
	public static void log(String e) {
		log(createStatus(e));
	}
	
	public static void log(Throwable e) {
		log("Error", e); //$NON-NLS-1$
	}
	
	public static void log(String message, Throwable e) {
		Throwable nestedException;
		if (e instanceof CModelException 
				&& (nestedException = ((CModelException)e).getException()) != null) {
			e = nestedException;
		}
		log(createStatus(message, e));
	}

	public static IStatus createStatus(String msg) {
		return createStatus(msg, null);
	}

	public static IStatus createStatus(String msg, Throwable e) {
		return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, msg, e);
	}
	
	public static void log(IStatus status) {
		getDefault().getLog().log(status);
	}

	private static Plugin getDefault() {
		return fInstance;
	}

}

Back to the top