aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2017-02-06 13:12:35 -0800
committerRyan Huber <rhuber@gmail.com>2017-02-06 13:12:35 -0800
commit2f653c80b355af63990c390313274f469bb2f3c1 (patch)
tree17c244ca62adeda57bb19809934fdb9072a21064
parent9e666945fc81f4220efffe79b3202ae39acd60e5 (diff)
downloadwee-slack-2f653c80b355af63990c390313274f469bb2f3c1.tar.gz
debug levels
-rw-r--r--wee_slack.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/wee_slack.py b/wee_slack.py
index b7f4f20..9e98456 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+#-*- coding: utf-8 -*-
#
import time
@@ -1729,7 +1729,7 @@ def handle_history(message_json, eventrouter, **kwargs):
clear = request_metadata.clear
except:
clear = False
- print clear
+ dbg(clear, 3)
kwargs['output_type'] = "backlog"
if clear:
w.buffer_clear(kwargs['channel'].channel_buffer)
@@ -2500,24 +2500,25 @@ def setup_hooks():
##### END NEW
-def dbg(message, main_buffer=False, fout=False):
+def dbg(message, level=0, main_buffer=False, fout=False):
"""
send debug output to the slack-debug buffer and optionally write to a file.
"""
#TODO: do this smarter
#return
- global debug_string
- message = "DEBUG: {}".format(message)
- # message = message.encode('utf-8', 'replace')
- if fout:
- file('/tmp/debug.log', 'a+').writelines(message + '\n')
- if main_buffer:
- #w.prnt("", "---------")
- w.prnt("", "slack: " + message)
- else:
- if slack_debug and (not debug_string or debug_string in message):
- #w.prnt(slack_debug, "---------")
- w.prnt(slack_debug, message)
+ if level >= config.debug_level:
+ global debug_string
+ message = "DEBUG: {}".format(message)
+ # message = message.encode('utf-8', 'replace')
+ if fout:
+ file('/tmp/debug.log', 'a+').writelines(message + '\n')
+ if main_buffer:
+ #w.prnt("", "---------")
+ w.prnt("", "slack: " + message)
+ else:
+ if slack_debug and (not debug_string or debug_string in message):
+ #w.prnt(slack_debug, "---------")
+ w.prnt(slack_debug, message)
###### Config code
@@ -2534,6 +2535,7 @@ class PluginConfig(object):
'colorize_nicks': 'true',
'colorize_private_chats': 'false',
'debug_mode': 'false',
+ 'debug_level': '3',
'distracting_channels': '',
'show_reaction_nicks': 'false',
'slack_api_token': 'INSERT VALID KEY HERE!',
@@ -2546,6 +2548,7 @@ class PluginConfig(object):
'thread_suffix_color': 'lightcyan',
'unhide_buffers_with_activity': 'false',
'short_buffer_names': 'false',
+ 'background_load_all_history': 'false',
}
# Set missing settings to their defaults. Load non-missing settings from
@@ -2596,6 +2599,9 @@ class PluginConfig(object):
def get_thread_suffix_color(self, key):
return w.config_get_plugin("thread_suffix_color")
+ def get_debug_level(self, key):
+ return int(w.config_get_plugin(key))
+
def get_slack_timeout(self, key):
return int(w.config_get_plugin(key))