Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: update log settings (#400)

NTFSvolume0574ae7c01a9
diff --git a/cyberdrop_dl/config_definitions/config_settings.py b/cyberdrop_dl/config_definitions/config_settings.py
index 556ef33a3..c44eb48fc 100644
--- a/cyberdrop_dl/config_definitions/config_settings.py
+++ b/cyberdrop_dl/config_definitions/config_settings.py
@@ -101,8 +101,8 @@ class IgnoreOptions(BaseModel):
class RuntimeOptions(BaseModel):
ignore_history: bool = False
- log_level: int = DEBUG
- console_log_level: int = 100
+ log_level: NonNegativeInt = DEBUG
+ console_log_level: NonNegativeInt = 100
skip_check_for_partial_files: bool = False
skip_check_for_empty_folders: bool = False
delete_partial_files: bool = False
diff --git a/cyberdrop_dl/utils/logger.py b/cyberdrop_dl/utils/logger.py
index 744f540b0..a277c8670 100644
--- a/cyberdrop_dl/utils/logger.py
+++ b/cyberdrop_dl/utils/logger.py
@@ -46,7 +46,8 @@ def log_with_color(message: str, style: str, level: int, show_in_stats: bool = T
"""Simple logging function with color."""
log(message, level, **kwargs)
text = Text(message, style=style)
- console.print(text)
+ if constants.CONSOLE_LEVEL >= 50:
+ console.print(text)
if show_in_stats:
constants.LOG_OUTPUT_TEXT.append_text(text.append("\n"))
@@ -54,7 +55,7 @@ def log_with_color(message: str, style: str, level: int, show_in_stats: bool = T
def log_spacer(level: int, char: str = "-", *, log_to_console: bool = True) -> None:
spacer = char * min(int(constants.DEFAULT_CONSOLE_WIDTH / 2), 50)
log(spacer, level)
- if log_to_console:
+ if log_to_console and constants.CONSOLE_LEVEL >= 50:
console.print("")
constants.LOG_OUTPUT_TEXT.append("\n", style="black")
diff --git a/docs/reference/configuration-options/settings/runtime_options.md b/docs/reference/configuration-options/settings/runtime_options.md
index f8d057631..e8fdef873 100644
--- a/docs/reference/configuration-options/settings/runtime_options.md
+++ b/docs/reference/configuration-options/settings/runtime_options.md
@@ -2,6 +2,39 @@
These are higher level options that effect the overarching functions of the program.
+## `log_level`
+
+| Type | Default |
+|----------------|----------|
+| `NonNegativeInt` | `10`|
+
+Defines the logging level for messages, according to [Python logging levels](https://docs.python.org/3/library/logging.html#levels). Messages with a level below this threshold will not be logged. Setting a value above 50 will disable logging entirely.
+
+| Level | Value | Description |
+|----------------|----------|----------|
+| `NOTSET` | 0 | All events are logged |
+| `DEBUG` | 10 | Offers detailed information, typically useful to troubleshoot problems |
+| `INFO` | 20 | Provides general information about scrape and download progress|
+| `WARNING` | 30 | Highlights a potential issue or something that might need attention (e.g. `Login wasn't provided for <FORUM>`)|
+| `ERROR` | 40 | Denotes a serious problem preventing Cyberdrop-DL to execute some function |
+| `CRITICAL` | 50 | Fatal error that causes Cyberdrop-DL to exit immediately |
+
+{% hint style="info" %}
+Using anything other that `DEBUG` makes troubleshooting issues harder. Practically speaking, this should only be adjusted if you expect CDL to run for an extended period (with a large number of input URLs) to minimize the log files sizes
+{% endhint %}
+
+## `console_log_level`
+
+| Type | Default |
+|----------------|----------|
+| `NonNegativeInt` | `100`|
+
+Same as `log_level` but it controls which messages are shown on the console.
+
+{% hint style="warning" %}
+Only use this option when running CDL with `--no-ui`; otherwise, the log messages might cause the UI screen to flicker.
+{% endhint %}
+
## `ignore_history`
| Type | Default |