Skip to content

Commit 0d13115

Browse files
authored
refactor: replace remaining instances of logging with structlog (TagStudioDev#1012)
1 parent 4105e17 commit 0d13115

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

src/tagstudio/core/media_types.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
44

55

6-
import logging
76
import mimetypes
87
from dataclasses import dataclass
98
from enum import Enum
109
from pathlib import Path
1110

12-
logging.basicConfig(format="%(message)s", level=logging.INFO)
11+
import structlog
12+
13+
logger = structlog.get_logger(__name__)
1314

1415
FILETYPE_EQUIVALENTS = [
1516
set(["aif", "aiff", "aifc"]),

src/tagstudio/main.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
"""TagStudio launcher."""
88

99
import argparse
10-
import logging
1110
import traceback
1211

1312
import structlog
1413

1514
from tagstudio.qt.ts_qt import QtDriver
1615

17-
structlog.configure(
18-
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
19-
)
16+
logger = structlog.get_logger(__name__)
2017

2118

2219
def main():
@@ -67,7 +64,7 @@ def main():
6764
driver.start()
6865
except Exception:
6966
traceback.print_exc()
70-
logging.info(f"\nTagStudio Frontend ({ui_name}) Crashed! Press Enter to Continue...")
67+
logger.info(f"\nTagStudio Frontend ({ui_name}) Crashed! Press Enter to Continue...")
7168
input()
7269

7370

src/tagstudio/qt/helpers/file_deleter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
44

55

6-
import logging
76
from pathlib import Path
87

8+
import structlog
99
from send2trash import send2trash
1010

11-
logging.basicConfig(format="%(message)s", level=logging.INFO)
11+
logger = structlog.get_logger(__name__)
1212

1313

1414
def delete_file(path: str | Path) -> bool:
@@ -19,13 +19,13 @@ def delete_file(path: str | Path) -> bool:
1919
"""
2020
_path = Path(path)
2121
try:
22-
logging.info(f"[delete_file] Sending to Trash: {_path}")
22+
logger.info(f"[delete_file] Sending to Trash: {_path}")
2323
send2trash(_path)
2424
return True
2525
except PermissionError as e:
26-
logging.error(f"[delete_file][ERROR] PermissionError: {e}")
26+
logger.error(f"[delete_file][ERROR] PermissionError: {e}")
2727
except FileNotFoundError:
28-
logging.error(f"[delete_file][ERROR] File Not Found: {_path}")
28+
logger.error(f"[delete_file][ERROR] File Not Found: {_path}")
2929
except Exception as e:
30-
logging.error(e)
30+
logger.error(e)
3131
return False

src/tagstudio/qt/widgets/landing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
44

55

6-
import logging
76
import sys
87
import typing
98
from pathlib import Path
109

10+
import structlog
1111
from PIL import Image, ImageQt
1212
from PySide6.QtCore import QEasingCurve, QPoint, QPropertyAnimation, Qt
1313
from PySide6.QtGui import QPixmap
@@ -21,7 +21,7 @@
2121
if typing.TYPE_CHECKING:
2222
from tagstudio.qt.ts_qt import QtDriver
2323

24-
logging.basicConfig(format="%(message)s", level=logging.INFO)
24+
logger = structlog.get_logger(__name__)
2525

2626

2727
class LandingWidget(QWidget):
@@ -153,7 +153,7 @@ def animate_logo_pop(self):
153153

154154
# def animate_status(self):
155155
# # if self.status_label.y() > 50:
156-
# logging.info(f"{self.status_label.pos()}")
156+
# logger.info(f"{self.status_label.pos()}")
157157
# self.status_pos_anim.setStartValue(
158158
# QPoint(self.status_label.x(), self.status_label.y() + 50)
159159
# )

0 commit comments

Comments
 (0)