Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Implement secret log level -1 (super verbose)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-WinnfieldX committed Feb 28, 2024
1 parent 0fc889a commit 3a133d4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.1.74"
__version__ = "5.1.75"
15 changes: 13 additions & 2 deletions cyberdrop_dl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ async def director(manager: Manager) -> None:
manager.log_manager.startup()

logger_debug = logging.getLogger("cyberdrop_dl_debug")
if os.getenv("PYCHARM_HOSTED") is not None:
from cyberdrop_dl.utils.utilities import DEBUG_VAR
if os.getenv("PYCHARM_HOSTED") is not None or manager.config_manager.settings_data['Runtime_Options']['log_level'] == -1:
manager.config_manager.settings_data['Runtime_Options']['log_level'] = 10
DEBUG_VAR = True

if DEBUG_VAR:
logger_debug.setLevel(manager.config_manager.settings_data['Runtime_Options']['log_level'])
file_handler_debug = logging.FileHandler("../cyberdrop_dl_debug.log", mode="w")
if os.getenv("PYCHARM_HOSTED") is not None:
file_handler_debug = logging.FileHandler("../cyberdrop_dl_debug.log", mode="w")
else:
file_handler_debug = logging.FileHandler("./cyberdrop_dl_debug.log", mode="w")
file_handler_debug.setLevel(manager.config_manager.settings_data['Runtime_Options']['log_level'])
formatter = logging.Formatter("%(levelname)-8s : %(asctime)s : %(filename)s:%(lineno)d : %(message)s")
file_handler_debug.setFormatter(formatter)
Expand All @@ -82,6 +90,9 @@ async def director(manager: Manager) -> None:

logger.setLevel(manager.config_manager.settings_data['Runtime_Options']['log_level'])
file_handler = logging.FileHandler(manager.path_manager.main_log, mode="w")

if DEBUG_VAR:
manager.config_manager.settings_data['Runtime_Options']['log_level'] = 10
file_handler.setLevel(manager.config_manager.settings_data['Runtime_Options']['log_level'])

formatter = logging.Formatter("%(levelname)-8s : %(asctime)s : %(filename)s:%(lineno)d : %(message)s")
Expand Down
8 changes: 5 additions & 3 deletions cyberdrop_dl/utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

MAX_NAME_LENGTHS = {"FILE": 95, "FOLDER": 60}

DEBUG_VAR = False

FILE_FORMATS = {
'Images': {
'.jpg', '.jpeg', '.png', '.gif',
Expand Down Expand Up @@ -94,20 +96,20 @@ async def wrapper(self, *args, **kwargs):
async def log(message: [str, Exception], level: int) -> None:
"""Simple logging function"""
logger.log(level, message)
if os.getenv("PYCHARM_HOSTED") is not None:
if DEBUG_VAR:
logger_debug.log(level, message)


async def log_debug(message: [str, Exception], level: int) -> None:
"""Simple logging function"""
if os.getenv("PYCHARM_HOSTED") is not None:
if DEBUG_VAR:
logger_debug.log(level, message)


async def log_with_color(message: str, style: str, level: int) -> None:
"""Simple logging function with color"""
logger.log(level, message)
if os.getenv("PYCHARM_HOSTED") is not None:
if DEBUG_VAR:
logger_debug.log(level, message)
rich.print(f"[{style}]{message}[/{style}]")

Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
version = "5.1.74"
version = "5.1.75"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 3a133d4

Please sign in to comment.