-
Notifications
You must be signed in to change notification settings - Fork 1
/
logging.py
36 lines (23 loc) · 839 Bytes
/
logging.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Logging module."""
import logging
import sublime
log = logging.getLogger("OpenContextPath")
def update_logger():
"""Update the logger based on the current settings."""
settings = sublime.load_settings("OpenContextPath.sublime-settings")
# set the verbosity level
if settings.get("debug", False):
log.setLevel(logging.DEBUG)
else:
log.setLevel(logging.INFO)
def plugin_loaded():
"""Initialize the logger."""
update_logger()
# track any changes to the settings
settings = sublime.load_settings("OpenContextPath.sublime-settings")
settings.add_on_change("logging", update_logger)
def plugin_unloaded():
"""Clean up."""
# remove our settings handler
settings = sublime.load_settings("OpenContextPath.sublime-settings")
settings.clear_on_change("logging")