Support full print()-style control in API.log()

This commit is contained in:
Juhani Krekelä 2018-02-25 21:18:28 +02:00
parent 53caed0d1c
commit b4233fda4a
1 changed files with 6 additions and 5 deletions

View File

@ -53,8 +53,9 @@ class LoggerThread(threading.Thread):
# Messages about status from the bot code # Messages about status from the bot code
elif message_type == logmessage_types.status: elif message_type == logmessage_types.status:
assert len(message_data) == 1 assert len(message_data) == 2
print('*', message_data[0]) print('*', end='')
print(*message_data[0], **message_data[1])
else: else:
print('???', message_type, message_data) print('???', message_type, message_data)
@ -127,9 +128,9 @@ class API:
with self.serverthread_object.channels_lock: with self.serverthread_object.channels_lock:
self.serverthread_object.channels = channels self.serverthread_object.channels = channels
def log(self, message): def log(self, *args, **kwargs):
"""Log a status message""" """Log a status message. Supports normal print() arguments."""
self.serverthread_object.logging_channel.send((logmessage_types.status, message)) self.serverthread_object.logging_channel.send((logmessage_types.status, args, kwargs))
def error(self, message): def error(self, message):
"""Log an error""" """Log an error"""