Introduction
Introduction Statistics Contact Development Disclaimer Help
Enable logging to a file - toot - Unnamed repository; edit this file 'descripti…
Log
Files
Refs
LICENSE
---
commit 508b4ff7eacf0bb54b827df661dbdcfaf548faf7
parent 455e531194a896490905a4e78c3a3dff10eb300b
Author: Ivan Habunek <[email protected]>
Date: Sun, 14 Jan 2018 15:34:41 +0100
Enable logging to a file
Diffstat:
toot/console.py | 7 ++++---
toot/logging.py | 4 ++++
2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/toot/console.py b/toot/console.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
+import os
import sys
import logging
@@ -9,7 +10,6 @@ from toot import config, commands, CLIENT_NAME, CLIENT_WEBSITE
from toot.exceptions import ApiError, ConsoleError
from toot.output import print_out, print_err
-
VISIBILITY_CHOICES = ['public', 'unlisted', 'private', 'direct']
@@ -305,9 +305,10 @@ def run_command(app, user, name, args):
def main():
- # Enable debug log if --debug is in args
+ # Enable debug logging if --debug is in args
if "--debug" in sys.argv:
- logging.basicConfig(level=logging.DEBUG)
+ filename = os.getenv("TOOT_LOG_FILE")
+ logging.basicConfig(level=logging.DEBUG, filename=filename)
# If something is piped in, append it to commandline arguments
if not sys.stdin.isatty():
diff --git a/toot/logging.py b/toot/logging.py
@@ -26,3 +26,7 @@ def log_response(response):
else:
logger.debug("<<< \033[31m{}\033[0m".format(response))
logger.debug("<<< \033[31m{}\033[0m".format(response.content))
+
+
+def log_debug(*msgs):
+ logger.debug(" ".join(str(m) for m in msgs))
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.