From 526740569b3ea61b5b3e655f743f111bd1910254 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sat, 3 Dec 2016 14:20:49 +0100 Subject: use logging module --- main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index ed33fc4..83d8b74 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ import pymongo import discord import asyncio import threading +import logging import parsedatetime import datetime @@ -18,13 +19,10 @@ cli = discord.Client() @cli.event async def on_ready(): - print("Logged in as") - print(cli.user.name) - print(cli.user.id) - print("-----") + log.warning("Logged in as " + cli.user.name + " (" + str(cli.user.id) + ")") def cleanup(): - print("purging old data from database") + log.warning("purging old data from database") now = datetime.datetime.utcnow() db.usercache.remove({ "date": {"$lt": now - datetime.timedelta(minutes=30)} @@ -72,7 +70,7 @@ async def search_teammates(who, query): "end": end }) - print(who.name + " requested a game " + ", ".join([str(d) for d in (start, end)])) + log.debug(who.name + " requested a game " + ", ".join([str(d) for d in (start, end)])) players = [] for teammate in db.playwithme.find({"end": {"$gt": start, "$lt": end}}): @@ -112,7 +110,7 @@ async def on_message(message): # if msg.startswith("\\getrole play"): # toggles the "play" role - print("toggled " + message.author.name + "'s play role") + log.debug("toggled " + message.author.name + "'s play role") for role in message.author.roles: if role.name == "play": await cli.remove_roles(message.author, role) @@ -125,5 +123,7 @@ async def on_message(message): await cli.send_message(message.channel, "Added the 'play' role.") if __name__ == '__main__': + logging.basicConfig() + log = logging.getLogger() threading.Timer(10 * 60, cleanup).start() cli.run(TOKEN) -- cgit v1.3.1