aboutsummaryrefslogtreecommitdiffstats
path: root/bot/__init__.py
diff options
context:
space:
mode:
authorGravatar Derek Fitzpatrick <[email protected]>2018-10-12 15:43:34 -0700
committerGravatar Derek Fitzpatrick <[email protected]>2018-10-12 15:43:34 -0700
commitd6051c5e8ef1a20b0833e67f75c5367df12e5622 (patch)
tree92ec894452eb4068a0553d531ac1515fb2d41ca8 /bot/__init__.py
parentFixed linting: Multiple imports on single line. (diff)
parentThe app was logging to the wrong directory. This is now fixed. Also silenced ... (diff)
Merge branch 'master' of https://github.com/discord-python/hacktoberbot into vote-monster-refactor
Diffstat (limited to 'bot/__init__.py')
-rw-r--r--bot/__init__.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/bot/__init__.py b/bot/__init__.py
index 1d320245..c411deb6 100644
--- a/bot/__init__.py
+++ b/bot/__init__.py
@@ -1,11 +1,11 @@
import logging.handlers
import os
+from pathlib import Path
# set up logging
-
-log_dir = 'log'
-log_file = log_dir + os.sep + 'hackbot.log'
+log_dir = Path("bot", "log")
+log_file = log_dir / "hackbot.log"
os.makedirs(log_dir, exist_ok=True)
# file handler sets up rotating logs every 5 MB
@@ -23,9 +23,15 @@ if root.handlers:
for handler in root.handlers:
root.removeHandler(handler)
-# setup new logging configuration
-logging.basicConfig(format='%(asctime)s - %(name)s %(levelname)s: %(message)s', datefmt="%D %H:%M:%S",
- level=logging.DEBUG,
- handlers=[console_handler, file_handler])
+# Silence irrelevant loggers
+logging.getLogger("discord").setLevel(logging.ERROR)
+logging.getLogger("websockets").setLevel(logging.ERROR)
-logging.info('Logging Process Started')
+# setup new logging configuration
+logging.basicConfig(
+ format='%(asctime)s - %(name)s %(levelname)s: %(message)s',
+ datefmt="%D %H:%M:%S",
+ level=logging.DEBUG,
+ handlers=[console_handler, file_handler]
+)
+logging.getLogger().info('Logging initialization complete')