Skip to content

Instantly share code, notes, and snippets.

@jonlabelle
Last active October 12, 2015 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonlabelle/3990598 to your computer and use it in GitHub Desktop.
Save jonlabelle/3990598 to your computer and use it in GitHub Desktop.
Quick-and-dirty Sublime Text 2 console event logger.
import sublime
import sublime_plugin
import time
class EventLog(sublime_plugin.EventListener):
def __init__(self):
print "--- Event Log Initialized ---"
sublime.status_message('--- Event Log Initialized ---')
# event log toggles
self.on_load_enabled = True
self.on_pre_save_enabled = True
self.on_post_save_enabled = True
self.on_new_enabled = True
self.on_modified_enabled = True
self.on_activated_enabled = True
self.on_deactivated_enabled = True
self.on_close_enabled = True
self.on_clone_enabled = True
self.on_query_completions_enabled = True
self.on_query_context_enabled = True
self.on_selection_modified_enabled = False
self.on_project_load_enabled = True
self.on_project_close_enabled = True
def on_load(self, view):
if self.on_load_enabled is True:
print view.file_name(), " --> loaded"
def on_pre_save(self, view):
if self.on_pre_save_enabled is True:
print view.file_name(), " --> pre save"
def on_post_save(self, view):
if self.on_post_save_enabled is True:
print view.file_name(), " --> saved"
def on_new(self, view):
if self.on_new_enabled is True:
print " --> new file created"
def on_modified(self, view):
if self.on_modified_enabled is True:
print view.file_name(), " --> modified"
def on_activated(self, view):
if self.on_activated_enabled is True:
print view.file_name(), " --> activated"
def on_deactivated(self, view):
if self.on_deactivated_enabled is True:
print view.file_name(), " --> deactivated"
def on_close(self, view):
if self.on_close_enabled is True:
print view.file_name(), " --> closed"
def on_clone(self, view):
if self.on_clone_enabled is True:
print view.file_name(), " --> cloned"
def on_query_completions(self, view, prefix, locations):
if self.on_query_completions_enabled is True:
print view.file_name(), " --> query completed"
def on_query_context(self, view, key, operator, operand, match_all):
if self.on_query_context_enabled is True:
print view.file_name(), " --> context queried"
def on_selection_modified(self, view):
if self.on_selection_modified_enabled is True:
print view.file_name(), ' --> selection modified (%s)' % time.time()
def on_project_load(self, view):
if self.on_project_load_enabled is True:
print view.file_name(), " --> project load"
def on_project_close(self, view):
if self.on_project_close_enabled is True:
print view.file_name(), " --> project close"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment