From f020829635a25b4d5b1c5cc951b031c5190fc809 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sat, 7 Dec 2024 15:35:44 +0900 Subject: [PATCH] Add logging to file --- labelme_toolkit/_cli/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/labelme_toolkit/_cli/__init__.py b/labelme_toolkit/_cli/__init__.py index 75d3125..5153b0e 100644 --- a/labelme_toolkit/_cli/__init__.py +++ b/labelme_toolkit/_cli/__init__.py @@ -1,3 +1,4 @@ +import os import sys import click @@ -16,9 +17,18 @@ @click.group(context_settings=dict(help_option_names=["-h", "--help"])) @click.version_option(__version__) def cli(): - logger.remove() + logger.remove(0) logger.add( - sys.stderr, level="INFO", colorize=True, format="{message}" + sys.stderr, + level="INFO", + colorize=True, + format="{message}", + backtrace=False, + diagnose=False, + ) + os.makedirs(os.path.expanduser("~/.cache/labelme"), exist_ok=True) + logger.add( + os.path.expanduser("~/.cache/labelme/toolkit.log"), colorize=True, level="DEBUG" )