diff options
author | Benoit Maggi | 2018-06-08 08:38:53 +0000 |
---|---|---|
committer | Patrick Tessier | 2018-06-08 12:53:50 +0000 |
commit | a97a60e3d283f6f8f664a686ca6b745124957912 (patch) | |
tree | ce90cdb542f765008a58bb960028cd05ff7b1cc0 /examples | |
parent | 7f14392e4a300cf3a70c364985a34659d7e3610f (diff) | |
download | org.eclipse.papyrus-a97a60e3d283f6f8f664a686ca6b745124957912.tar.gz org.eclipse.papyrus-a97a60e3d283f6f8f664a686ca6b745124957912.tar.xz org.eclipse.papyrus-a97a60e3d283f6f8f664a686ca6b745124957912.zip |
Bug 535676 - [Example] Spam logs
- a debug option is required to see the logs
- debug is kept private to avoid any API change
Change-Id: I86769235ebd8149ce759eb6c47d31f4b18e9d6cc
Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java index d953a968de8..e8e3efd2c3a 100644 --- a/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java +++ b/examples/core/org.eclipse.papyrus.example.core.lifecycleevents/src/org/eclipse/papyrus/example/core/lifecycleevents/LifeCycleEventsMonitorService.java @@ -14,6 +14,7 @@ package org.eclipse.papyrus.example.core.lifecycleevents; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.papyrus.infra.core.services.IService; import org.eclipse.papyrus.infra.core.services.ServiceException; @@ -33,6 +34,12 @@ import org.eclipse.papyrus.infra.ui.lifecycleevents.ISaveEventListener; * */ public class LifeCycleEventsMonitorService implements IService { + + private static final String DEBUG_KEY = "org.eclipse.papyrus.example.core.lifecycleevents/debug"; //$NON-NLS-1$ + + private boolean isDebugEnabled() { + return Boolean.TRUE.toString().equalsIgnoreCase(Platform.getDebugOption(DEBUG_KEY)); + } protected ServicesRegistry servicesRegistry; /** @@ -46,11 +53,11 @@ public class LifeCycleEventsMonitorService implements IService { protected ISaveEventListener aboutToSaveListener = new ISaveEventListener() { public void doSaveAs(DoSaveEvent event) { - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: aboutToSaveAs")); + if (isDebugEnabled()) { Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: aboutToSaveAs"));}; } public void doSave(DoSaveEvent event) { - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: aboutToSave")); + if (isDebugEnabled()) { Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: aboutToSave"));}; } }; @@ -60,11 +67,11 @@ public class LifeCycleEventsMonitorService implements IService { protected ISaveEventListener saveListener= new ISaveEventListener() { public void doSaveAs(DoSaveEvent event) { - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: doSaveAs")); + if (isDebugEnabled()) {Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: doSaveAs"));}; } public void doSave(DoSaveEvent event) { - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: doSave")); + if (isDebugEnabled()) {Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: doSave"));}; } }; @@ -74,11 +81,11 @@ public class LifeCycleEventsMonitorService implements IService { protected ISaveEventListener postSaveListener= new ISaveEventListener() { public void doSaveAs(DoSaveEvent event) { - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: postSaveAs")); + if (isDebugEnabled()) {Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: postSaveAs"));}; } public void doSave(DoSaveEvent event) { - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: postSave")); + if (isDebugEnabled()) {Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "event received: postSave"));}; } }; @@ -90,7 +97,7 @@ public class LifeCycleEventsMonitorService implements IService { * @param servicesRegistry */ public LifeCycleEventsMonitorService() { - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "LifeCycleEventsMonitorService created")); + if (isDebugEnabled()) {Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "LifeCycleEventsMonitorService created"));}; } /** @@ -99,7 +106,7 @@ public class LifeCycleEventsMonitorService implements IService { */ public void disposeService() { deactivate(); - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "LifeCycleEventsMonitorService disposed")); + if (isDebugEnabled()) {Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "LifeCycleEventsMonitorService disposed"));}; } @@ -118,7 +125,7 @@ public class LifeCycleEventsMonitorService implements IService { * */ public void startService() { - Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "LifeCycleEventsMonitorService started")); + if (isDebugEnabled()) {Activator.getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "LifeCycleEventsMonitorService started"));}; activate(); } @@ -132,7 +139,7 @@ public class LifeCycleEventsMonitorService implements IService { eventProvider.addDoSaveListener(saveListener); eventProvider.addPostDoSaveListener(postSaveListener); } catch (ServiceException e) { - Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage())); + if (isDebugEnabled()) {Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));}; } @@ -148,5 +155,4 @@ public class LifeCycleEventsMonitorService implements IService { } - } |