You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support configure logging fmt of setup_logger (#5846)
## Changes Made
1. support configure log format and date format
2. enable all logger by default
3. modify documentation to easy setup.
## Related Issues
<!-- Link to related GitHub issues, e.g., "Closes#123" -->
-`datefmt` (str, optional): The date format to use in the log format. Defaults to `"%Y-%m-%d %H:%M:%S.%s"`.
39
42
40
43
By default, `setup_logger()` sets the root logger to `DEBUG` level and applies a filter to only show logs from Daft modules. This makes it easier to focus on Daft-specific logs while debugging.
41
44
@@ -44,7 +47,7 @@ For most use cases, simply using `logging.getLogger(__name__)` is the common fir
44
47
!!! note
45
48
- It's important to set the logging level before importing Daft, as the underlying Rust components will not pick up level changes that occur after the import.
46
49
47
-
- After each logger setup,` refresh_logger()` is called to synchronize the configuration with the Rust backend.
50
+
- The `setup_logger()` doesn't have the above mentioned side effects. The ` refresh_logger()` will been called to synchronize the configuration with the Rust backend if use `setup_logger()`.
48
51
## Remote Execution
49
52
50
53
When running Daft on a Ray cluster, logging is more complex due to the distributed nature of the system. Logs can be emitted from the driver process (where you call `ray.init()`) or from the worker processes (where the actual data processing happens).
@@ -60,15 +63,15 @@ Here are a few ways to configure logging when using Daft with Ray:
60
63
61
64
1.**Suppressing Worker Logs on the Driver**: By default, Ray forwards logs from all worker processes to the driver, which can be overwhelming. If you only want to see driver logs, you can disable this behavior by setting `log_to_driver=False` in `ray.init()`:
62
65
63
-
```python
64
-
import ray
66
+
```python
67
+
import ray
65
68
66
-
ray.init(log_to_driver=False)
67
-
```
69
+
ray.init(log_to_driver=False)
70
+
```
68
71
69
72
2.**Per-Worker Logging Configuration**: If you need to set different logging levels for different modules on each worker, you can use a `worker_process_setup_hook`. This is a function that runs at the start of each worker process, allowing you to configure logging before any Daft code is executed.
70
73
71
-
Here is an example of how to define a setup hook to configure logging on each worker:
74
+
Here is an example of how to define a setup hook to configure logging on each worker, and also you can use `setup_logger()` to configure logging.
72
75
73
76
```python
74
77
defconfigure_logging():
@@ -103,28 +106,16 @@ Here is a complete example of how to initialize Ray with a combination of these
0 commit comments