Skip to content

Commit

Permalink
undeprecate configure_from_file - YAML is useful
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmaslanka committed Dec 13, 2024
1 parent 34cef6c commit 5f3496f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ History
--------------------

* made the configuration a little bit more Pythonic
* deprecated `configure_from_dict` and `configure_from_file`
* deprecated `configure_from_dict`
* you can choose whether ConsoleStructuredLogHandler will log to stdout or to stderr.

0.4.0 - (2024-12-8)
Expand Down
4 changes: 1 addition & 3 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ The formal definition of the configure function is as follows:
Configure logging from a file
-----------------------------

.. deprecated:: 0.5.0
Use logging.config.dictConfig() directly

Seqlog can also use a YAML-format file to describe the desired logging configuration. This file has the schema specified in Python's `logging.config <https://docs.python.org/3/library/logging.config.html#logging-config-dictschema>`_ module.

First, create your configuration file (e.g. ``/foo/bar/my_config.yml``):
Expand Down Expand Up @@ -142,6 +139,7 @@ This dictionary has the schema specified in Python's `logging.config <https://do
Note that you can pass flags that were previously given to :func:`seqlog.configure_from_dict` directly in the dictionary, eg.

.. autofunction:: seqlog.configure_from_dict

.. code-block:: python
Expand Down
10 changes: 5 additions & 5 deletions seqlog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import logging
import logging.config
import typing
import warnings

import yaml

from seqlog.feature_flags import FeatureFlag, configure_feature
Expand All @@ -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):
Expand All @@ -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)


Expand Down

0 comments on commit 5f3496f

Please sign in to comment.