Home Download Buy Blog Forum Support

SublimeLog — On-the-fly ST2 console logging

SublimeLog — On-the-fly ST2 console logging

Postby yrammos on Fri Jun 22, 2012 3:42 am

I just released the first version of this very simple plugin to dump a log of the ST2 console into the disk.

The plugin is available at https://github.com/yrammos/SublimeLog.

Please note that I've only been able to test this on a OS X, so please do let me know of any issues should you have a Linux or Windows machine.

The package is not yet available via Package Control but I will submit it there as soon as I have a couple of confirmations that it works well on Linux and Windows.

Instructions and important notes are available on GitHub.

Enjoy!

* * *

As a collateral benefit, this plugin should meet the needs of those who have been wishing a separate console window. To do this, just open your terminal and run:

Code: Select all
tail -f ~/.subl.log


… possibly replacing ~/.subl.log with the path and name of your log file.

This will provide you with a live stream of the ST2 console output in the terminal window.

On Windows, the tail command is available as part of the GNU Utilities for Win32 package http://unxutils.sourceforge.net/.
yrammos
 
Posts: 18
Joined: Fri Jun 22, 2012 3:26 am

Re: SublimeLog — On-the-fly ST2 console logging

Postby RyanJ on Fri Jun 22, 2012 3:34 pm

Thanks, this seems to work pretty well on Win-64. Oddly not everything in the console gets logged however (notably the 'Writing file /C/blah.txt with encoding UTF-8' messages don't get logged.

I'd like to see an option to automatically enable logging on startup if possible.
RyanJ
 
Posts: 18
Joined: Mon Sep 26, 2011 1:59 pm

Re: SublimeLog — On-the-fly ST2 console logging

Postby yrammos on Mon Jul 30, 2012 11:50 am

Thanks for your feedback, RyanJ, and my apologies for the belated response. I somehow failed to notice the topic.

Indeed, a small number of messages are not logged by the package, including the one you mention ("Writing file…"). Another class of such messages are actual Python commands typed at the console prompt. For example, if you open the console and type

Code: Select all
print "Hello"

the window will display

Code: Select all
>>> print "Hello"
Hello

but SublimeLog will only log

Code: Select all
Hello

I have so far not discovered any other classes of "missed" messages and, to my knowledge, everything else gets captured as expected.

I have been unable to figure out the cause of this glitch. It is possible that Sublime Text does not use the standard output pipe — which is "wiretapped" by the logger plugin — for these recalcitrant messages.

I am sorry for the inconvenience and will be sure to update the plugin accordingly if I come across a "clean" workaround.
yrammos
 
Posts: 18
Joined: Fri Jun 22, 2012 3:26 am

Re: SublimeLog — On-the-fly ST2 console logging

Postby joushou on Wed Aug 01, 2012 7:54 am

yrammos wrote:Thanks for your feedback, RyanJ, and my apologies for the belated response. I somehow failed to notice the topic.

Indeed, a small number of messages are not logged by the package, including the one you mention ("Writing file…"). Another class of such messages are actual Python commands typed at the console prompt. For example, if you open the console and type

Code: Select all
print "Hello"

the window will display

Code: Select all
>>> print "Hello"
Hello

but SublimeLog will only log

Code: Select all
Hello

I have so far not discovered any other classes of "missed" messages and, to my knowledge, everything else gets captured as expected.

I have been unable to figure out the cause of this glitch. It is possible that Sublime Text does not use the standard output pipe — which is "wiretapped" by the logger plugin — for these recalcitrant messages.

I am sorry for the inconvenience and will be sure to update the plugin accordingly if I come across a "clean" workaround.


The output "collected" by the console is part python stdout (all plugins), and part sublime itself. By tapping into stdout in a plugin, you're only achieving half of what sublime is doing, as sublime is capable of writing directly to the console (as with the interactive prompt, "Writing file"; blah blah).
Maybe sublime has an interface for gathering this, but I kind of doubt it. Still useful for keeping track of plugins under development that crash sublime, though! (that is, assuming you're too lazy to manually open a logfile yourself. This does it for you.)
joushou
 
Posts: 4
Joined: Sun Feb 26, 2012 11:18 pm

Re: SublimeLog — On-the-fly ST2 console logging

Postby yrammos on Sat Aug 11, 2012 11:46 am

joushou wrote:The output "collected" by the console is part python stdout (all plugins), and part sublime itself. By tapping into stdout in a plugin, you're only achieving half of what sublime is doing, as sublime is capable of writing directly to the console (as with the interactive prompt, "Writing file"; blah blah).
Maybe sublime has an interface for gathering this, but I kind of doubt it. Still useful for keeping track of plugins under development that crash sublime, though! (that is, assuming you're too lazy to manually open a logfile yourself. This does it for you.)


This indeed appears to be the case: the core application is able to print on the console directly, circumnavigating the Python environment, and my package does not capture such output. It might be possible to find a user-accessible hook for it — I haven't looked hard — but it seems a bit unlikely.

If it is any consolation, in my experience by far most of the console content —— and I would venture to say the most useful stuff —— is directed through the Python environment, therefore captured by SublimeLog. For others though, this limitation might be disconcerting.

joushou wrote:Still useful for keeping track of plugins under development that crash sublime, though! (that is, assuming you're too lazy to manually open a logfile yourself. This does it for you.


This is not the only use case. Several packages use the console to output messages, for example LaTeXTools and Package Control. The former was actually my motivation for writing SublimeLog in the first place. :-)
yrammos
 
Posts: 18
Joined: Fri Jun 22, 2012 3:26 am


Return to Plugin Announcements

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests