summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2018-04-03 12:37:46 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2018-04-03 12:37:46 +0200
commit6a5f362ccced3f2c6704c22712de0d6ceb9a5a4d (patch)
treee0c4faa954cf3c9090f928662f30322ba9f12edc
parent2a20179c47c7a28c8cca05e1913126f95886197c (diff)
downloadragequitte-6a5f362ccced3f2c6704c22712de0d6ceb9a5a4d.tar.gz
ragequitte-6a5f362ccced3f2c6704c22712de0d6ceb9a5a4d.zip
improve logging
-rw-r--r--grabbers/discord_to_redis.py12
-rw-r--r--processors/redis_to_word2vec.py8
2 files changed, 13 insertions, 7 deletions
diff --git a/grabbers/discord_to_redis.py b/grabbers/discord_to_redis.py
index 0b21d26..f5b850a 100644
--- a/grabbers/discord_to_redis.py
+++ b/grabbers/discord_to_redis.py
@@ -1,10 +1,16 @@
#!/usr/bin/python3
+import logging
+import asyncio
+
import discord
import redis
-import asyncio
+
import config
+logging.basicConfig(level=logging.INFO)
+logger = logging.getLogger(__name__)
+
client = discord.Client()
r = redis.StrictRedis(**{ **config.redis, "decode_responses": True })
@@ -23,11 +29,11 @@ def store_message(message):
@client.event
async def on_message(message):
- print(message.content)
+ logging.info("{}#{}@{}: {}".format(message.server.name, message.channel.name, message.author.name, message.clean_content))
fetch_history = store_message(message)
if fetch_history:
- print("+++ fetching channel history +++")
+ logging.info("+++ fetching channel history +++")
try:
async for logmsg in client.logs_from(message.channel, before=message, limit=100000):
store_message(logmsg)
diff --git a/processors/redis_to_word2vec.py b/processors/redis_to_word2vec.py
index 752ee37..fd5f521 100644
--- a/processors/redis_to_word2vec.py
+++ b/processors/redis_to_word2vec.py
@@ -97,12 +97,12 @@ class RedisIterator(object):
def discord_batch_handler(message):
global model_updating
- print("building vocabulary")
+ logging.info("building vocabulary")
model.build_vocab(RedisIterator(match="message:*", deleting=False), update=model_updating)
- print("vocabulary size: {}".format(len(model.wv.vocab)))
- print("training")
+ logging.info("vocabulary size: {}".format(len(model.wv.vocab)))
+ logging.info("training")
model.train(RedisIterator(match="message:*", deleting=True), total_examples=model.corpus_count, epochs=model.epochs)
- print("trained")
+ logging.info("trained")
model.save(config.model)
model_updating = True
if config.debug: