Show warnings in the (window) status bar
@@ -7,16 +7,19 @@ from . import util
DEBUG_FALSE_LEVEL = logging.WARNING
DEBUG_TRUE_LEVEL = logging.INFO
ERROR_PANEL_LEVEL = logging.ERROR
+STATUS_BAR_LEVEL = logging.WARNING
logger = logging.getLogger('SublimeLinter')
logger.setLevel(logging.DEBUG)
handler = None
error_panel_handler = None
+status_bar_handler = None
def install():
install_std_handler()
install_error_panel_handler()
+ install_status_bar_handler()
settings = sublime.load_settings("SublimeLinter.sublime-settings")
settings.add_on_change('SublimeLinter._logging', install_std_handler)
@@ -27,6 +30,8 @@ def uninstall():
logger.removeHandler(handler)
if error_panel_handler:
logger.removeHandler(error_panel_handler)
+ if status_bar_handler:
+ logger.removeHandler(status_bar_handler)
settings = sublime.load_settings("SublimeLinter.sublime-settings")
settings.clear_on_change('SublimeLinter._logging')
@@ -61,7 +66,7 @@ def install_std_handler():
handler.setLevel(level)
logger.addHandler(handler)
- logger.setLevel(min(ERROR_PANEL_LEVEL, level))
+ logger.setLevel(min(ERROR_PANEL_LEVEL, STATUS_BAR_LEVEL, level))
logger.info(
'Logging installed; log level {}'.format(logging.getLevelName(level))
)
@@ -83,6 +88,19 @@ def install_error_panel_handler():
logger.addHandler(error_panel_handler)
+def install_status_bar_handler():
+ global status_bar_handler
+ if status_bar_handler:
+ logger.removeHandler(status_bar_handler)
+
+ formatter = TaskNumberFormatter(fmt="SublimeLinter: {message}", style="{")
+ status_bar_handler = StatusBarHandler()
+ status_bar_handler.setFormatter(formatter)
+ status_bar_handler.setLevel(STATUS_BAR_LEVEL)
+
+ logger.addHandler(status_bar_handler)
+
+
class TaskNumberFormatter(logging.Formatter):
def format(self, record):
thread_name = record.threadName
@@ -112,3 +130,13 @@ class ErrorPanelHandler(logging.Handler):
util.message(msg)
except Exception:
self.handleError(record)
+
+
+class StatusBarHandler(logging.Handler):
+ def emit(self, record):
+ try:
+ msg = self.format(record)
+ window = sublime.active_window()
+ window.status_message(msg)
+ except Exception:
+ self.handleError(record)
