Skip to content

config_root_logger() does not work for non web #30

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Closed
ggtools opened this issue Sep 5, 2019 · 1 comment
Closed

config_root_logger() does not work for non web #30

ggtools opened this issue Sep 5, 2019 · 1 comment

Comments

@ggtools
Copy link
Contributor

ggtools commented Sep 5, 2019

With version 1.0.3, python 3.7 on Mac OS X on a freshly created virtual env.

Simple program:

import logging
import json_logging

# log is initialized without a web framework name
json_logging.ENABLE_JSON_LOGGING = True
json_logging.init_non_web()

logging.basicConfig(level=logging.DEBUG)

json_logging.config_root_logger()

logger = logging.getLogger("test logger")

logger.info("test log statement")
logger.info("test log statement", extra={'props': {"extra_property": 'extra_value'}})

Fails with the following error:

Traceback (most recent call last):
  File "root_logger.py", line 10, in <module>
    json_logging.config_root_logger()
  File "/Users/xtof/Documents/Dev/Python/json-logging/venv/lib/python3.7/site-packages/json_logging/__init__.py", line 90, in config_root_logger
    request_logger = _current_framework['app_request_instrumentation_configurator']().get_request_logger()
TypeError: 'NoneType' object is not subscriptable
@ggtools ggtools changed the title config_root_logger() does not work config_root_logger() does not work for non web Sep 5, 2019
ggtools added a commit to ggtools/json-logging-python that referenced this issue Sep 5, 2019
- Fix  condition  to choose between web and non web configuration
- Run the `request_logger` part only in web configuration

Issue bobbui#30
@bobbui
Copy link
Owner

bobbui commented Sep 6, 2019

release 1.0.4 to fix this issue

@bobbui bobbui closed this as completed Sep 6, 2019
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants