Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5d3ab96ec0c3e7e16792ae243b1fd873d0446dda (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*******************************************************************************
 * Copyright (c) 2010-2011 Composent, Inc. 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:
 *   Composent, Inc. - initial API and implementation
 ******************************************************************************/
package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.core.util.Trace;

public class LogUtility {

	public static void logError(String methodName, String debugOption,
			Class clazz, String message) {
		logError(methodName, debugOption, clazz, message, null);
		traceException(methodName, debugOption, clazz, message, null);
	}

	public static void logWarning(String methodName, String debugOption,
			Class clazz, String message) {
		trace(methodName, debugOption, clazz, "WARNING:" + message); //$NON-NLS-1$
		Activator.getDefault().log(
				new Status(IStatus.WARNING, Activator.PLUGIN_ID,
						IStatus.WARNING, clazz.getName() + ":" //$NON-NLS-1$
								+ ((methodName == null) ? "<unknown>" //$NON-NLS-1$
										: methodName) + ":" //$NON-NLS-1$
								+ ((message == null) ? "<empty>" : message), //$NON-NLS-1$
						null));
	}

	public static void logError(String methodName, String debugOption,
			Class clazz, String message, Throwable t) {
		if (t != null)
			traceException(methodName, debugOption, clazz, message, t);
		else
			trace(methodName, debugOption, clazz, message);
		Activator.getDefault().log(
				new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
						clazz.getName() + ":" //$NON-NLS-1$
								+ ((methodName == null) ? "<unknown>" //$NON-NLS-1$
										: methodName) + ":" //$NON-NLS-1$
								+ ((message == null) ? "<empty>" //$NON-NLS-1$
										: message), t));
	}

	public static void logWarning(String methodName, String debugOption,
			Class clazz, String message, Throwable t) {
		if (t != null)
			traceException(methodName, debugOption, clazz, message, t);
		else
			trace(methodName, debugOption, clazz, message);
		Activator.getDefault().log(
				new Status(IStatus.WARNING, Activator.PLUGIN_ID,
						IStatus.WARNING, clazz.getName() + ":" //$NON-NLS-1$
								+ ((methodName == null) ? "<unknown>" //$NON-NLS-1$
										: methodName) + ":" //$NON-NLS-1$
								+ ((message == null) ? "<empty>" //$NON-NLS-1$
										: message), t));
	}

	public static void logError(String methodName, String debugOption,
			Class clazz, IStatus status) {
		Throwable t = status.getException();
		if (t != null)
			traceException(methodName, debugOption, clazz, status.getMessage(),
					t);
		else
			trace(methodName, debugOption, clazz, status.getMessage());
		Activator.getDefault().log(status);
	}

	public static void logWarning(String methodName, String debugOption,
			Class clazz, IStatus status) {
		logError(methodName, debugOption, clazz, status);
	}

	public static void trace(String methodName, String debugOptions,
			Class clazz, String message) {
		Trace.trace(Activator.PLUGIN_ID, debugOptions, clazz, methodName,
				message);
	}

	public static void traceException(String methodName, String debugOption,
			Class clazz, String message, Throwable t) {
		Trace.catching(Activator.PLUGIN_ID, debugOption, clazz,
				((methodName == null) ? "<unknown>" : methodName) + ":" //$NON-NLS-1$ //$NON-NLS-2$
						+ ((message == null) ? "<empty>" : message), t); //$NON-NLS-1$
	}

}

Back to the top