Page 1 of 3

Log redirector and filter

Posted: Wed Oct 20, 2010 3:26 pm
by Pako
I have in one PC installed EventGhost as a "service".
It's not obviously a really service, but EventGhost is started before user logon.
This is done using the Windows Scheduler (option When my computer starts (before a user logs on).
The problem is that in this case is not available EventGhost window and therefore the log.
That's why I made this plugin that allows you to save the log to a text file.
I think this plugin can be used in other situations too.
I made only very short tests, and so I do not know how the plugin will behave after prolonged use.

Pako

EDIT 2015-03-17: added new version 0.1.0

Re: Log redirector

Posted: Wed Oct 20, 2010 4:41 pm
by stottle
EG uses a list to store the log messages I believe, with a size of 2000 or 10000 lines (I forget which). Would it be possible to do the same in this case, where the txt file is kept to some line count? What would be really interesting would be to push the logged lines into the UI once the users logs in, too.

Interesting idea, Pako.

Brett

Re: Log redirector

Posted: Wed Oct 20, 2010 6:18 pm
by krambriw
Hi Pako, I used a similar idea to create log files because I wanted to read the log data from remote (also over internet). In my case I wanted them to be easy to view with a browser so I created them with extension .html instead of .txt

Each time you then write a new line to the log file, you can add this string at the end "<br\n>" and it will look ok in the browser

But it depends of course what you want to do with the log data. If you want to parse & extract something, .txt is just fine

Best regards, Walter

Re: Log redirector

Posted: Thu Oct 21, 2010 8:09 am
by Pako
Dear Walter!
krambriw wrote:In my case I wanted them to be easy to view with a browser so I created them with extension .html instead of .txt
I do not understand. All my browsers correctly display the contents of txt files (not ignoring the larger number of space characters in a row - that is, indent).
What are the advantages html extension? I tried it, but it is much worse than the txt format. I would have to insert some formatting tags to the right indent.

BTW: I forgot one very important thing.
Log redirector plugin should be placed as high in the branch Autostart.

Best regards, Pako

Re: Log redirector

Posted: Thu Oct 21, 2010 8:52 am
by miljbee
Excellent Pako,

I have always been annoyed by the log system of eg.
My main problem is that I have a high rate of events in my tree, and when I want to check something, I usually don't have the time to see what happens, the log scrolls really to fast.

With your plugin (which I haven't tested yet), I will be able to look at what happens from the text file. It will be far more usable for me.

A nice feature for your plugin would be to implement filters. I have no precise idea of how you could do that, but usually, when you need the log, you don't need what is known to work.

I will try your plugin ASAP.

Thank you !

Re: Log redirector

Posted: Thu Oct 21, 2010 1:55 pm
by krambriw
Dear Pako,
I just remember I once had problems to show .txt files in Internet browsers (the format did not display well and I always had to confirm that I wanted to open the .txt file) This was some years ago and maybe this is not a problem any more with recent browsers

Best regards, Walter

Re: Log redirector

Posted: Fri Oct 22, 2010 9:50 am
by miljbee
This is a really great plugin for debugging a very busy tree.

Anyway, I would like to be able to specify the "commit interval" in seconds. Having to wait at least one minute to see what has happened when you are debugging is a bit long.

And as written above, implementing filters would be awesome. Since everything in eg is driven by events, it would be great to filter them (and the macro they trigger).

For exemple, in the conf dialog of the plugin, we could have 2 fields to define filters for exclusion or inclusion.
In these fields we would write event Names.

when logging to a file, your plugin should match the event name defined in the exclusion filters. If it matches, then do nothing until next event. If it doesn't match, write log file until next event.
It's the same for inclusion filter : if it matches an event from the inclusion list, then write log to file until next event.

I had a quick look at your code to see if I could implement this by myself, but haven't understand anything ... I am to bad with python !

Regards,

Re: Log redirector

Posted: Sun Oct 31, 2010 12:22 pm
by Pako
I was some time away from the internet and in the meantime I made some improvements to the plugin.

1) Version 0.0.1
This version has added feature of monitoring the size of the log file.
You can choose the maximum size (max 999 MiB). Once it reached the selected size of the file, file is truncated (of course the latest entries are kept).
The size of the truncated file it is also possible to choose.
__init__.py
Version 0.0.1
(14.74 KiB) Downloaded 626 times
2) Version 0.0.2
This version has added the possibility of filtering events. I do not think that this option will be used by many people.
But because it was not difficult to implement this feature, so I did.
There was also changed the unit of file commit interval. Now that figure is in seconds. So be careful when upgrading from version 0.0.0!
__init__.py
Version 0.0.2
(26.86 KiB) Downloaded 650 times
Pako

Re: Log redirector

Posted: Thu Nov 04, 2010 12:33 pm
by miljbee
Great work Pako !

This plugin will greatly ease my dev/debug sessions.

It's in my tree, and I think it will stay here forever !

Thank You !

Re: Log redirector

Posted: Thu Mar 24, 2011 7:54 am
by krambriw
Dear Pako,
I just tried to add the plugin Version 0.0.2 but I got the following error message (using eg 0.4.0 r1397)
Version 0.0.1 works ok
Best regards, Walter

Code: Select all

08:51:26   Traceback (most recent call last) (1397):
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\TaskletDialog.py", line 59, in ProcessingTask
08:51:26       self.Configure(*args, **kwargs)
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\ConfigDialog.py", line 161, in Configure
08:51:26       treeItem.Configure(*args)
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\ActionItem.py", line 100, in Configure
08:51:26       return self.executable.Configure(*args)
08:51:26     File "C:\Program Files\EventGhost\plugins\LogRedirector\__init__.py", line 728, in Configure
08:51:26       onRadioBox()
08:51:26     File "C:\Program Files\EventGhost\plugins\LogRedirector\__init__.py", line 724, in onRadioBox
08:51:26       onFilterChoice()
08:51:26     File "C:\Program Files\EventGhost\plugins\LogRedirector\__init__.py", line 675, in onFilterChoice
08:51:26       Validation()
08:51:26     File "C:\Program Files\EventGhost\plugins\LogRedirector\__init__.py", line 623, in Validation
08:51:26       flg_1 = len(self.logfile) > 0
08:51:26   TypeError: object of type 'NoneType' has no len()
08:51:26   Traceback (most recent call last) (1397):
08:51:26     File "wx\_core.pyc", line 14618, in <lambda>
08:51:26     File "C:\Program Files\EventGhost\eg\Core.py", line 172, in Notify
08:51:26       listener(value)
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\MainFrame\TreeCtrl.py", line 783, in OnNodeAdded
08:51:26       pos
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\MainFrame\TreeCtrl.py", line 458, in CreateTreeItemAt
08:51:26       return self.CreateTreeItem(node, parentId)
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\MainFrame\TreeCtrl.py", line 446, in CreateTreeItem
08:51:26       node.SetAttributes(self, itemId)
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\PluginItem.py", line 86, in SetAttributes
08:51:26       if self.info.lastException or self.info.initFailed:
08:51:26   AttributeError: 'NoneType' object has no attribute 'lastException'
08:51:26   Traceback (most recent call last) (1397):
08:51:26     File "wx\_core.pyc", line 14618, in <lambda>
08:51:26     File "C:\Program Files\EventGhost\eg\Core.py", line 172, in Notify
08:51:26       listener(value)
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\MainFrame\TreeCtrl.py", line 829, in OnNodeSelected
08:51:26       path = node.GetPath()
08:51:26     File "C:\Program Files\EventGhost\eg\Classes\TreeItem.py", line 354, in GetPath
08:51:26       path.append(parent.childs.index(item))
08:51:26   AttributeError: 'NoneType' object has no attribute 'childs'

Re: Log redirector

Posted: Thu Mar 24, 2011 11:48 am
by Pako
Dear Walter!
Thanks for the warning on a bug. This bug did not show up when you perform an upgrade plugin
(which was already included in the configuration). Therefore, I am about him not knowing.
Now you can download the fixed version 0.0.3.
You'll find it in the first article (on top) of the topic.

Best regards, Pako

Re: Log redirector

Posted: Thu Jun 23, 2011 9:51 pm
by Livin
Pako,
This is great... I wish I had looked for this a while ago... I could have really used it when testing/troubleshooting from a remote PC.

awesome work!

Re: Log redirector

Posted: Tue Oct 11, 2011 1:27 am
by ijourneaux
Pako

I tried installing the Log Redirector plugin (v.6). I can bring up the config page but I amunable to adjust any of the settings. Any thoughts on what I could try.

Take Care

Re: Log redirector

Posted: Tue Oct 11, 2011 11:31 am
by Pako
ijourneaux wrote:I can bring up the config page but I amunable to adjust any of the settings. Any thoughts on what I could try.
Maybe there is some error in the plugin, but more likely is that you are doing something incorrectly.
But how can I know what? Maybe a screenshot would help.

Pako

Re: Log redirector

Posted: Thu Oct 13, 2011 2:58 am
by ijourneaux
Sorry Pako. I really didn't give you much to work with. I did figure it out though. At first I didn't understand the logging mode options. I thought the Log EventGhost only meant log eventghost evetns to log file and couldn't figure out why I couldn't specify a file.

Now that I correctly read the options correctly it is clear what you meant

option 1 log eventghost events to eventghost window
option 2 log eventghost events to eventghost window and log file
option 3 log eventghost events to log file