kopia lustrzana https://github.com/ihabunek/toot
Enable logging to a file
rodzic
455e531194
commit
508b4ff7ea
|
@ -1,5 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -9,7 +10,6 @@ from toot import config, commands, CLIENT_NAME, CLIENT_WEBSITE
|
||||||
from toot.exceptions import ApiError, ConsoleError
|
from toot.exceptions import ApiError, ConsoleError
|
||||||
from toot.output import print_out, print_err
|
from toot.output import print_out, print_err
|
||||||
|
|
||||||
|
|
||||||
VISIBILITY_CHOICES = ['public', 'unlisted', 'private', 'direct']
|
VISIBILITY_CHOICES = ['public', 'unlisted', 'private', 'direct']
|
||||||
|
|
||||||
|
|
||||||
|
@ -305,9 +305,10 @@ def run_command(app, user, name, args):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Enable debug log if --debug is in args
|
# Enable debug logging if --debug is in args
|
||||||
if "--debug" in sys.argv:
|
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 something is piped in, append it to commandline arguments
|
||||||
if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
|
|
|
@ -26,3 +26,7 @@ def log_response(response):
|
||||||
else:
|
else:
|
||||||
logger.debug("<<< \033[31m{}\033[0m".format(response))
|
logger.debug("<<< \033[31m{}\033[0m".format(response))
|
||||||
logger.debug("<<< \033[31m{}\033[0m".format(response.content))
|
logger.debug("<<< \033[31m{}\033[0m".format(response.content))
|
||||||
|
|
||||||
|
|
||||||
|
def log_debug(*msgs):
|
||||||
|
logger.debug(" ".join(str(m) for m in msgs))
|
||||||
|
|
Ładowanie…
Reference in New Issue