feat(logging): add log_path parameter to setup_logger for file output#6410
feat(logging): add log_path parameter to setup_logger for file output#6410
Conversation
Greptile SummaryThis PR adds an optional Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["setup_logger(level, log_path, ...)"] --> B["Validate level & normalise to upper-case"]
B --> C["logging.basicConfig / root_logger.setLevel"]
C --> D["Iterate snapshot of root_logger.handlers"]
D --> E{"handler is\n_DaftFileHandler?"}
E -- Yes --> F["removeHandler + handler.close()"]
E -- No --> G["handler.filters.clear()"]
F --> H{"log_path\nis not None?"}
G --> H
H -- Yes --> I["Path.expanduser().resolve()"]
I --> J["Validate path.name is non-empty"]
J --> K["path.parent.mkdir(parents=True)"]
K --> L["Create _DaftFileHandler(path)"]
L --> M["Set level, formatter → addHandler"]
H -- No --> N["Skip file handler"]
M --> O{"daft_only?"}
N --> O
O -- Yes --> P["Add daft-name filter to all handlers"]
O -- No --> Q{"exclude_prefix?"}
P --> Q
Q -- Yes --> R["Add prefix-exclusion filter to all handlers"]
Q -- No --> S["refresh_logger()"]
R --> S
Last reviewed commit: fe9337c |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6410 +/- ##
==========================================
+ Coverage 74.78% 76.92% +2.13%
==========================================
Files 1020 1020
Lines 136319 136325 +6
==========================================
+ Hits 101949 104867 +2918
+ Misses 34370 31458 -2912
🚀 New features to boost your workflow:
|
universalmind303
left a comment
There was a problem hiding this comment.
I don't think this is the right approach. This adds convenience for writing debug logs to a file, but users can already do this with Python's standard logging with just 4 loc:
handler = logging.FileHandler("/path/to/log")
handler.setFormatter(logging.Formatter("..."))
logging.getLogger().addHandler(handler)
setup_logger("debug")More importantly, the direction we want to move for observability is toward a structured event timeline. giving users visibility into what Daft is actually doing (query planning, partition execution, data reads, etc.) rather than capturing unstructured debug log lines. Adding log_path here commits us to API surface we'd likely deprecate once a proper observability layer is in place.
Changes Made
This adds an option to write logs to a file