Created
November 9, 2011 16:44
-
-
Save sra448/1352028 to your computer and use it in GitHub Desktop.
sublime text 2 command for tailing and greping the rails logfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin, os | |
class TailCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
from datetime import datetime | |
filtertext = "FLO" | |
# open sublime console | |
self.view.window().run_command("show_panel", { "panel": "console", "toggle": "true" }) | |
# show log as output | |
folder = self.view.window().folders()[0] | |
print datetime.now() | |
print ">> open " + folder + "/log/development.log:" | |
log = os.popen("tail " + folder + "/log/development.log -n 200 | grep " + filtertext).readlines() | |
if len(log) == 0: | |
print ">> no matches for FLO" | |
else: | |
for line in log: | |
print ">> " + line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment