Bug 173040 - [logview] Allow to open view upon .log entry
Summary: [logview] Allow to open view upon .log entry
Status: CLOSED WONTFIX
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: bugday
: 209162 (view as bug list)
Depends on: 220891
Blocks:
  Show dependency tree
 
Reported: 2007-02-06 08:08 EST by Dani Megert CLA
Modified: 2019-11-08 04:37 EST (History)
5 users (show)

See Also:


Attachments
mylyn/context/zip (731 bytes, application/octet-stream)
2007-11-07 20:10 EST, Chris Aniszczyk CLA
no flags Details
patch (2.95 KB, patch)
2008-02-29 01:33 EST, Jacek Pospychala CLA
no flags Details | Diff
patch (6.41 KB, patch)
2008-02-29 06:50 EST, Jacek Pospychala CLA
no flags Details | Diff
patch (3.24 KB, patch)
2008-02-29 08:44 EST, Jacek Pospychala CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2007-02-06 08:08:46 EST
I20070207-0010.

When something is written to std out or err I can choose that the Console view is shown i.e. opened if not yet open. I would like the same option for the Error log view.

Currently I am forced to
1. manually open it the first time
2. make it a fast view
3. let it stay around as fast view even though I normally don't want to see it

From now on the view is activated on a log entry because the view menu's activate menu item is checked.
Comment 1 Chris Aniszczyk CLA 2007-11-07 20:10:10 EST
tagging bugday
Comment 2 Chris Aniszczyk CLA 2007-11-07 20:10:15 EST
Created attachment 82402 [details]
mylyn/context/zip
Comment 3 Jacek Pospychala CLA 2008-01-06 08:02:39 EST
There are a couple of ways to do this:
1. Log View in target Eclipse adds itself as a log listener immediately at platform start instead during plug-in start. Then Log View wouldn't be lazy any more = bad.
2. Log View in host Eclipse automatically opens target Eclipse log. Requires Log View to listen on log changes in file system, which requires polling = bad.
3. Log View in host Eclipse eats stdout instead of Console. That's doable, but then user wouldn't have console. = bad.

I'll try 2. and if it is really that bad, go for 3....
Comment 4 Chris Aniszczyk CLA 2008-01-07 10:49:12 EST
*** Bug 209162 has been marked as a duplicate of this bug. ***
Comment 5 Benjamin Cabé CLA 2008-02-13 12:42:23 EST
I'll probably have a look at this one, I'm definitely in my logview days :)

Being loglistener in the "target" Eclipse sounds like a better solution to me.
The feature should work even for someone who's not developing plugins and just uses the logview as a "final user", right ?
Comment 6 Jacek Pospychala CLA 2008-02-13 12:45:20 EST
(In reply to comment #5)
> I'll probably have a look at this one, I'm definitely in my logview days :)
> 
> Being loglistener in the "target" Eclipse sounds like a better solution to me.
> The feature should work even for someone who's not developing plugins and just
> uses the logview as a "final user", right ?

yes, the only drawback is that logview plug-in wouldn't be lazy loaded any more.

Comment 7 Benjamin Cabé CLA 2008-02-15 17:37:41 EST
(In reply to comment #6)
> yes, the only drawback is that logview plug-in wouldn't be lazy loaded any
> more.
> 

How about if we registered a LogListener on PDEPlugin initialization ?
Something like :

Platform.addLogListener(new ILogListener() {
  public void logging(IStatus status, String plugin) {
    try {
      PlatformUI.getWorkbench().
        getActiveWorkbenchWindow().getActivePage().
        showView("org.eclipse.pde.runtime.LogView");
    } catch (PartInitException e) {
  }
}

It works well, but the feature would then need PDEPlugin to work, and the log view is now totally independent ...
Comment 8 Jacek Pospychala CLA 2008-02-27 13:10:09 EST
good idea Ben this would fix the bug.

But the other thing that makes me sad is that given that we're working on having hyperlinks in error log, it would make sense to show error log view in host Eclipse. There we could open hyperlinks because user's all plug-in code is in host workspace.

Since we have log browser in error log, it would be easy to automatically switch in host error log view to display launched Eclipse instance log.
Ah but that requires also catching up with log changes, or streaming  log directly to host listener.
Comment 9 Dani Megert CLA 2008-02-28 03:49:26 EST
The suggested fix from comment 7 is a no go as it would make the feature unpredictable since it depends on PDE UI being loaded.

>1. Log View in target Eclipse adds itself as a log listener immediately at
>platform start instead during plug-in start. Then Log View wouldn't be lazy any
>more = bad.
There is no other way. The log view plug-in should offer that preference which is off by default and if enabled the log view plug-in is started on start up where it adds the listener. This is not so bad as this is a small plug-in. Also, the preference can warn the user:

[ ] Show when on an entry is logged (activates Log view plug-in on startup)


Re comment 8: please don't let your additional wishes hold off fixing this bug. My request is to open the view in workbench X if a log entry for it is written. If you have more ideas I suggest to file a new enhancement request ;-)
Comment 10 Jacek Pospychala CLA 2008-02-28 04:01:58 EST
(In reply to comment #9)
> The suggested fix from comment 7 is a no go as it would make the feature
> unpredictable since it depends on PDE UI being loaded.
> 
> >1. Log View in target Eclipse adds itself as a log listener immediately at
> >platform start instead during plug-in start. Then Log View wouldn't be lazy any
> >more = bad.
> There is no other way. The log view plug-in should offer that preference which
> is off by default and if enabled the log view plug-in is started on start up
> where it adds the listener. This is not so bad as this is a small plug-in.
> Also, the preference can warn the user:
> 
> [ ] Show when on an entry is logged (activates Log view plug-in on startup)

hm I thought of using org.eclipse.ui.startup ext point to make this plugin start early, but there's no way to add any preference there.
Were you thinking of any other particular way to early start this plugin?
Comment 11 Dani Megert CLA 2008-02-28 04:29:16 EST
>hm I thought of using org.eclipse.ui.startup ext point to make this plugin
>start early, but there's no way to add any preference there.
The log view could add its own preference page but the real show stoppers here are:
1. the startup extension cannot be off by default
2. there is no API for clients to disable an auto-start plug-in - only users can do this via UI currently.

Platform UI would have to enhance the extension point and provide an API along the lines of IWorkbench.setEarlyActivatedPlugin(String pluginId, boolean state).

For now a simple "fix" would be to offer a simple plug-in that I can add to my install which simply implements this feature. Users that install it know what they do and can disable it via General > Startup and Shutdown.

Once Platform UI has provided the additional APIs the code can move to the log view plug-in.
Comment 12 Jacek Pospychala CLA 2008-02-29 01:33:45 EST
Created attachment 91116 [details]
patch

Now in early startup Activator adds itself as framework listener and on first coming log entry shows view.
Quite like Ben described, but all happens in logview plug-in, not pde.ui.
Hope Dani, you'll like it.

Thank you both for making it happen :)
I'll check if there's any bug for Platform UI changes outlined by Dani and if not create new.
Comment 13 Jacek Pospychala CLA 2008-02-29 01:38:28 EST
(In reply to comment #12)
> Now in early startup Activator adds itself as framework listener and on first

I mean framework log listener (org.eclipse.core.runtime.ILogListener)
Comment 14 Jacek Pospychala CLA 2008-02-29 02:09:11 EST
(In reply to comment #12)
> I'll check if there's any bug for Platform UI changes outlined by Dani and if
> not create new.

created bug 220891

Comment 15 Dani Megert CLA 2008-02-29 05:28:47 EST
We should not do this until bug 220891 is fixed. Besides that the patch has two problems:

1. it uses the deprecated version of the extension point which relies on the compatibility plug-in. Instead, a new class that implements IStartup should be introduced and registered.

2. it does not remove the listener when the plug-in is stopped.
Comment 16 Jacek Pospychala CLA 2008-02-29 05:37:12 EST
(In reply to comment #15)
> We should not do this until bug 220891 is fixed. Besides that the patch has two
> problems:

correct. I also found another problem that makes it necessary to use separate IStartup, not only Activator.

Comment 17 Jacek Pospychala CLA 2008-02-29 06:50:29 EST
Created attachment 91157 [details]
patch

Patch updated to:
- define a separate IStartup class.
- unregister loglistener on bundle stop
- add a preference within LogView which tells if view should be opened or not. I found that regardless IStartup, view is usually started anyway because pde.ui depends on it. This way view popped up even if IStartup was disabled.

With this patch, to enable early startup one will have to open view for first time, uncheck "Activate on new events" and check it again. Then say YES to additional question "Do you want to activate view even if it's closed? Answering no view will be activated only if it's already visible."[*].
That's because by default earlyStartup is disabled but "active on new events" is enabled.

When bug 220891 gets fixed, one will also have to enable earlyStartup as well.

It's most hidden feature of 3.4 :)

[*] - this message may need rewording.
Comment 18 Dani Megert CLA 2008-02-29 08:16:50 EST
>I found that regardless IStartup, view is usually started anyway because pde.ui
>depends on it.
Yes, if Package Explorer or Project Explorer is open and the ExternalPluginLibrariesFilter enabled.


>This way view popped up even if IStartup was disabled.
This is because your patch is wrong. IStartup.earlyStartup() is not called when disabled. Of course you must add the listener there and not in start().
Comment 19 Jacek Pospychala CLA 2008-02-29 08:41:29 EST
(In reply to comment #18)
> This is because your patch is wrong. IStartup.earlyStartup() is not called when
> disabled. Of course you must add the listener there and not in start().


ok, I assumed if plugin is already started, then earlyStartup is not executed.
indeed wrong :|
Comment 20 Jacek Pospychala CLA 2008-02-29 08:44:20 EST
Created attachment 91174 [details]
patch

compared to previous patch:
- register log listener in IStartup.earlyStartup()
- get rid of confirm dialog. wait for bug 220891 to do enable/disable
Comment 21 Dani Megert CLA 2011-02-28 07:05:50 EST
On a second thought we should use the startup extension point. We would have to synchronize the Error log view preference with the startup preference and the other way around. This is strange for the user. Also, the plug-in would show up on the 'Startup and Shutdown' preference page which it shouldn't (the loading is an implementation detail).

A better solution would be a new extension point where plug-ins can register for log events via extension point.
Comment 22 Thomas Watson CLA 2011-03-03 09:28:29 EST
(In reply to comment #21)
> 
> A better solution would be a new extension point where plug-ins can register
> for log events via extension point.

I would prefer something that used the new ExtendedLogReader service in Equinox instead of introducing a new extension point.  Unfortunately the ExtendedLogReader service suffers from the same issue as the ILogListener where you must progratically register the listener.  We could allow LogListeners to be registered as OSGi services.  This would allow you to use DS to declare a LogListener.  But other details would need to be worked out, such as how to declaratively define a LogFilter so that you only get the log entries that go to the .log file.

I'm not sure I have time to contain such a change in 3.7 though.
Comment 23 Dani Megert CLA 2011-03-03 10:39:39 EST
>  We could allow LogListeners to
> be registered as OSGi services.  This would allow you to use DS to declare a
> LogListener.  But other details would need to be worked out, such as how to
> declaratively define a LogFilter so that you only get the log entries that go
> to the .log file.
> 
> I'm not sure I have time to contain such a change in 3.7 though.
There's no rush. I'm happy if we can put it on the plate for 3.8.
Comment 24 Lars Vogel CLA 2019-11-08 04:37:14 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant please remove the stalebug whiteboard tag.