-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUG] Use python logging level (#2705)
Example script: ``` import daft print("Only warnings and errors should print") daft.daft.test_logging() print("\nSetting logging level to debug, all messages should print") from daft.logging import setup_debug_logger setup_debug_logger() daft.daft.test_logging() ``` Output: ``` Only warnings and errors should print WARN from rust ERROR from rust Setting logging level to debug, all messages should print DEBUG:daft.pylib:DEBUG from rust INFO:daft.pylib:INFO from rust WARNING:daft.pylib:WARN from rust ERROR:daft.pylib:ERROR from rust ``` --------- Co-authored-by: Colin Ho <colinho@Colins-MBP.localdomain> Co-authored-by: Colin Ho <colinho@Colins-MacBook-Pro.local>
- Loading branch information
1 parent
3647b26
commit bf5c853
Showing
4 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import logging | ||
|
||
import pytest | ||
|
||
|
||
def test_logger_initialization(): | ||
import daft | ||
|
||
rust_level = daft.daft.get_max_log_level() | ||
|
||
assert rust_level == "WARN" | ||
|
||
|
||
def test_debug_logger(): | ||
import daft | ||
from daft.logging import setup_debug_logger | ||
|
||
setup_debug_logger() | ||
rust_level = daft.daft.get_max_log_level() | ||
assert rust_level == "DEBUG" | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"level, expected", | ||
[ | ||
(logging.DEBUG, "DEBUG"), | ||
(logging.INFO, "INFO"), | ||
(logging.WARNING, "WARN"), | ||
(logging.ERROR, "ERROR"), | ||
], | ||
) | ||
def test_refresh_logger(level, expected): | ||
import logging | ||
|
||
import daft | ||
|
||
logging.getLogger().setLevel(level) | ||
daft.daft.refresh_logger() | ||
|
||
rust_level = daft.daft.get_max_log_level() | ||
assert rust_level == expected |