Skip to content

Commit

Permalink
Merge pull request #11 from tintoy/fix/issue10
Browse files Browse the repository at this point in the history
Fix incorrect behaviour when configuring Seq
  • Loading branch information
tintoy committed Aug 11, 2018
2 parents 4bf767e + e0bd7be commit 0a6f110
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ indent_size = 2
insert_final_newline = true
charset = utf-8

[*.rst]
trim_trailing_whitespace = false

[*.bat]
indent_style = tab
end_of_line = crlf
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
History
=======

0.3.10 (2018-08-11)
-------------------

* Fix incorrect behaviour when configuring logging from a file (tintoy/seqlog#10).
**Breaking change**: Configuring logging from file or dict will now by default override the default logger class to be ``StructuredLogger`` (this can be reverted to previous behaviour by passing ``use_structured_logger=False``).

0.3.9 (2018-01-09)
------------------

Expand Down
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: seqlog
version: 0.3.9
version: 0.3.10

requirements:
host:
Expand Down
13 changes: 10 additions & 3 deletions seqlog/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import logging
import logging.config
import yaml

from seqlog.structured_logging import StructuredLogger, StructuredRootLogger
Expand All @@ -12,10 +13,10 @@

__author__ = 'Adam Friedman'
__email__ = 'tintoy@tintoy.io'
__version__ = '0.3.9'
__version__ = '0.3.10'


def configure_from_file(file_name, override_root_logger=True):
def configure_from_file(file_name, override_root_logger=True, use_structured_logger=True):
"""
Configure Seq logging using YAML-format configuration file.
Expand All @@ -24,6 +25,7 @@ def configure_from_file(file_name, override_root_logger=True):
:param file_name: The name of the configuration file to use.
:type file_name: str
:param override_root_logger: Override the root logger to use a Seq-specific implementation? (default: True)
:param use_structured_logger: Configure the default logger class to be StructuredLogger, which support named format arguments? (default: True)
:type override_root_logger: bool
"""

Expand All @@ -33,7 +35,7 @@ def configure_from_file(file_name, override_root_logger=True):
configure_from_dict(config, override_root_logger)


def configure_from_dict(config, override_root_logger=True):
def configure_from_dict(config, override_root_logger=True, use_structured_logger=True):
"""
Configure Seq logging using a dictionary.
Expand All @@ -42,12 +44,17 @@ def configure_from_dict(config, override_root_logger=True):
:param config: A dict containing the configuration.
:type config: dict
:param override_root_logger: Override the root logger to use a Seq-specific implementation? (default: True)
:param use_structured_logger: Configure the default logger class to be StructuredLogger, which support named format arguments? (default: True)
:type override_root_logger: bool
"""

if override_root_logger:
_override_root_logger()

# Must use StructuredLogger to support named format argments.
if (use_structured_logger):
logging.setLoggerClass(StructuredLogger)

logging.config.dictConfig(config)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

setup(
name='seqlog',
version='0.3.9',
version='0.3.10',
description="SeqLog enables logging from Python to Seq.",
long_description=readme + '\n\n' + history,
author="Adam Friedman",
Expand Down

0 comments on commit 0a6f110

Please sign in to comment.