🔊 add FileHandler to logging

This commit is contained in:
oskvr37
2025-02-07 12:51:23 +01:00
parent a67e965146
commit a5f521e3c2
3 changed files with 20 additions and 4 deletions
+14 -2
View File
@@ -6,6 +6,8 @@ from .auth import AuthGroup
from .download import UrlGroup, FavGroup, SearchGroup, FileGroup
from .config import ConfigCommand
from tiddl.config import HOME_PATH
@click.group()
@passContext
@@ -18,9 +20,19 @@ def cli(ctx: Context, verbose: bool):
# add more verbosity options (silent, info, debug),
# maybe logging format configuration
# latest logs
file_handler = logging.FileHandler(HOME_PATH / "tiddl.log", mode="w", encoding="utf-8")
file_handler.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG if verbose else logging.INFO)
logging.basicConfig(
level=logging.DEBUG if verbose else logging.INFO,
handlers=[logging.StreamHandler()],
level=logging.DEBUG,
handlers=[
stream_handler,
file_handler,
],
format="%(levelname)s [%(name)s.%(funcName)s] %(message)s",
)
+2 -2
View File
@@ -3,8 +3,8 @@ from pathlib import Path
from tiddl.models.constants import TrackArg
CONFIG_PATH = Path.home() / "tiddl.json"
HOME_PATH = Path.home()
CONFIG_PATH = HOME_PATH / "tiddl.json"
CONFIG_INDENT = 2
+4
View File
@@ -23,8 +23,12 @@ def addMetadata(
cover_data=b"",
credits: List[AlbumItemsCredits.ItemWithCredits.CreditsEntry] = [],
):
logger.debug((track_path, track.id))
extension = track_path.suffix
# TODO: handle mutagen exceptions
if extension == ".flac":
metadata = MutagenFLAC(track_path)
if cover_data: