-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
undeprecate configure_from_file - YAML is useful
- Loading branch information
1 parent
34cef6c
commit a7434d5
Showing
2 changed files
with
6 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
import logging | ||
import logging.config | ||
import typing | ||
import warnings | ||
|
||
import yaml | ||
|
||
from seqlog.feature_flags import FeatureFlag, configure_feature | ||
|
@@ -16,23 +18,20 @@ | |
|
||
__author__ = 'Adam Friedman' | ||
__email__ = '[email protected]' | ||
__version__ = '0.5.0a1' | ||
__version__ = '0.5.0' | ||
|
||
|
||
def configure_from_file(file_name): | ||
""" | ||
Configure Seq logging using YAML-format configuration file. | ||
.. deprecated: 0.5.0 | ||
Use logging.config.fileConfig(). Also, let it be known that Python uses different format natively (your file cannot be YAML) | ||
Uses `logging.config.dictConfig()`. | ||
""" | ||
|
||
with open(file_name) as config_file: | ||
config = yaml.load(config_file, Loader=yaml.SafeLoader) | ||
|
||
configure_from_dict(config) | ||
logging.config.dictConfig(config) | ||
|
||
|
||
def configure_from_dict(config): | ||
|
@@ -49,6 +48,7 @@ def configure_from_dict(config): | |
:param config: A dict containing the configuration. | ||
:type config: dict | ||
""" | ||
warnings.warn('This is deprecated, use logging.config.dictConfig() directly', DeprecationWarning) | ||
logging.config.dictConfig(config) | ||
|
||
|
||
|