[core] fix up the logging a bit
This commit is contained in:
parent
1f056c0cb5
commit
89bc27515c
1 changed files with 8 additions and 6 deletions
|
@ -37,13 +37,14 @@ class RtmBot(object):
|
||||||
path = os.path.join(os.getcwd(), self.directory)
|
path = os.path.join(os.getcwd(), self.directory)
|
||||||
self.directory = os.path.abspath(path)
|
self.directory = os.path.abspath(path)
|
||||||
|
|
||||||
|
self.debug = self.config.get('DEBUG', False)
|
||||||
|
|
||||||
# establish logging
|
# establish logging
|
||||||
log_file = config.get('LOGFILE', 'rtmbot.log')
|
log_file = config.get('LOGFILE', 'rtmbot.log')
|
||||||
logging.basicConfig(filename=log_file,
|
logging.basicConfig(filename=log_file,
|
||||||
level=logging.INFO,
|
level=logging.DEBUG if self.debug else logging.INFO,
|
||||||
format='%(asctime)s %(module)s %(levelname)s: %(message)s')
|
format='%(asctime)s %(module)s %(levelname)s: %(message)s')
|
||||||
logging.info('Initialized in: {}'.format(self.directory))
|
logging.info('Initialized in: {}'.format(self.directory))
|
||||||
self.debug = self.config.get('DEBUG', False)
|
|
||||||
|
|
||||||
# initialize stateful fields
|
# initialize stateful fields
|
||||||
self.last_ping = 0
|
self.last_ping = 0
|
||||||
|
@ -51,8 +52,7 @@ class RtmBot(object):
|
||||||
self.slack_client = SlackClient(self.token)
|
self.slack_client = SlackClient(self.token)
|
||||||
|
|
||||||
def _dbg(self, debug_string):
|
def _dbg(self, debug_string):
|
||||||
if self.debug:
|
logging.debug(debug_string)
|
||||||
logging.info(debug_string)
|
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""Convenience method that creates Server instance"""
|
"""Convenience method that creates Server instance"""
|
||||||
|
@ -149,9 +149,11 @@ class Plugin(object):
|
||||||
|
|
||||||
def register_jobs(self):
|
def register_jobs(self):
|
||||||
if 'crontable' in dir(self.module):
|
if 'crontable' in dir(self.module):
|
||||||
for interval, function in self.module.crontable:
|
crontable = self.module.crontable
|
||||||
|
if crontable:
|
||||||
|
logging.info('registering crontable: %s', self.module.crontable)
|
||||||
|
for interval, function in crontable:
|
||||||
self.jobs.append(Job(interval, eval("self.module." + function), self.debug))
|
self.jobs.append(Job(interval, eval("self.module." + function), self.debug))
|
||||||
logging.info(self.module.crontable)
|
|
||||||
self.module.crontable = []
|
self.module.crontable = []
|
||||||
else:
|
else:
|
||||||
self.module.crontable = []
|
self.module.crontable = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue