Skip to content

Commit

Permalink
Fix #61 Using root logger + flask outside of flask request context th…
Browse files Browse the repository at this point in the history
…rows RuntimeError
  • Loading branch information
Bob Bui committed Oct 15, 2020
1 parent bb12bf0 commit d9171fa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## 1.2.8 - 2020-10-15
- Fix #61 Using root logger + flask outside of flask request context throws RuntimeError

## 1.2.8 - 2020-08-27
- Fix #57

Expand Down
5 changes: 4 additions & 1 deletion json_logging/framework/connexion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def set_correlation_id(self, request_, value):
_connexion.g.correlation_id = value

def get_correlation_id_in_request_context(self, request):
return _connexion.g.get('correlation_id', None)
try:
return _connexion.g.get('correlation_id', None)
except:
return None

def get_protocol(self, request):
return request.environ.get('SERVER_PROTOCOL')
Expand Down
5 changes: 4 additions & 1 deletion json_logging/framework/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def set_correlation_id(self, request_, value):
_flask.g.correlation_id = value

def get_correlation_id_in_request_context(self, request):
return _flask.g.get('correlation_id', None)
try:
return _flask.g.get('correlation_id', None)
except:
return None

def get_protocol(self, request):
return request.environ.get('SERVER_PROTOCOL')
Expand Down
5 changes: 4 additions & 1 deletion json_logging/framework/quart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def set_correlation_id(self, request_, value):
_quart.g.correlation_id = value

def get_correlation_id_in_request_context(self, request):
return _quart.g.get('correlation_id', None)
try:
return _quart.g.get('correlation_id', None)
except:
return None

def get_protocol(self, request):
return request.scheme
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="json-logging",
version='1.2.8',
version='1.2.9',
packages=find_packages(exclude=['contrib', 'docs', 'tests*', 'example', 'dist', 'build']),
license='Apache License 2.0',
description="JSON Python Logging",
Expand Down

0 comments on commit d9171fa

Please sign in to comment.