Author: adietish
Date: 2010-10-15 07:56:50 -0400 (Fri, 15 Oct 2010)
New Revision: 25861
Added:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/ILoggingAdapter.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/PluginLogger.java
Log:
[JBIDE-7320] moved from usage to common in order to use it in deltacloud, too
Copied:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/ILoggingAdapter.java
(from rev 25860,
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/tracker/ILoggingAdapter.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/ILoggingAdapter.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/ILoggingAdapter.java 2010-10-15
11:56:50 UTC (rev 25861)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.log;
+
+/**
+ * @author Andre Dietisheim
+ */
+public interface ILoggingAdapter {
+
+ public void error(String errorMessage);
+
+ public void debug(String message);
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/ILoggingAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/PluginLogger.java
(from rev 25860,
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/tracker/internal/PluginLogger.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/PluginLogger.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/log/PluginLogger.java 2010-10-15
11:56:50 UTC (rev 25861)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.log;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.jboss.tools.usage.util.LoggingUtils;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class PluginLogger implements ILoggingAdapter {
+
+ private final boolean tracingEnabled;
+
+ private Plugin plugin;
+
+ public PluginLogger(Plugin plugin) {
+ this.tracingEnabled = LoggingUtils.isPluginTracingEnabled(plugin);
+ this.plugin = plugin;
+ }
+
+ public void error(String message) {
+ log(IStatus.ERROR, message);
+ }
+
+ public void debug(String message) {
+ log(IStatus.INFO, message);
+ }
+
+ private void log(int severity, String message) {
+ if (!tracingEnabled) {
+ return;
+ }
+
+ if (plugin != null) {
+ IStatus status = new Status(severity, plugin.getBundle().getSymbolicName(), message);
+ plugin.getLog().log(status);
+ }
+ }
+}