Use logging module for informational prints
This commit is contained in:
parent
bdb9387d91
commit
a018aeb1c3
30
ahtcg_bot.py
30
ahtcg_bot.py
@ -4,6 +4,7 @@ import configargparse
|
||||
from datetime import datetime
|
||||
import json
|
||||
import re
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
import discord
|
||||
@ -56,11 +57,11 @@ class ArkhamDBUpdater(commands.Bot):
|
||||
json.dump(list(self.channel_list), f)
|
||||
|
||||
async def on_ready(self) -> None:
|
||||
print(f"Logged in as {self.user} (ID: {self.user.id})")
|
||||
print("Enabled on servers:")
|
||||
logging.info(f"Logged in as {self.user} (ID: {self.user.id})")
|
||||
logging.info("Enabled on servers:")
|
||||
async for guild in self.fetch_guilds(limit=150):
|
||||
print(" -", guild.name)
|
||||
print("------")
|
||||
logging.info(f" - {guild.name}")
|
||||
logging.info("------")
|
||||
|
||||
self.arkhamdb_monitor.start()
|
||||
|
||||
@ -109,7 +110,7 @@ class ArkhamDBUpdater(commands.Bot):
|
||||
return status
|
||||
|
||||
async def update_channel_latest_decks(self, channel: discord.TextChannel) -> None:
|
||||
print(f"Running update in channel {channel.guild} - {channel.name}")
|
||||
logging.info(f"Running update in channel {channel.guild} - {channel.name}")
|
||||
async with channel.typing():
|
||||
deck_ids = await self.gather_deck_ids(channel)
|
||||
latest_decks = await self.arkhamdb_client.get_latest_decks(deck_ids)
|
||||
@ -200,8 +201,27 @@ def main():
|
||||
help="Discord API token",
|
||||
env_var="DISCORD_TOKEN",
|
||||
)
|
||||
parser.add(
|
||||
"-d",
|
||||
"--debug",
|
||||
help="Print lots of debugging statements",
|
||||
action="store_const",
|
||||
dest="loglevel",
|
||||
const=logging.DEBUG,
|
||||
default=logging.WARNING,
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
help="Be verbose",
|
||||
action="store_const",
|
||||
dest="loglevel",
|
||||
const=logging.INFO,
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=args.loglevel)
|
||||
|
||||
bot = ArkhamDBUpdater(
|
||||
channel_list_file=args.channel_list, command_prefix="!arkhamdb "
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user