Skip to content

Commit d9171fa

Browse files
author
Bob Bui
committed
Fix #61 Using root logger + flask outside of flask request context throws RuntimeError
1 parent bb12bf0 commit d9171fa

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## 1.2.8 - 2020-10-15
8+
- Fix #61 Using root logger + flask outside of flask request context throws RuntimeError
9+
710
## 1.2.8 - 2020-08-27
811
- Fix #57
912

json_logging/framework/connexion/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ def set_correlation_id(self, request_, value):
9090
_connexion.g.correlation_id = value
9191

9292
def get_correlation_id_in_request_context(self, request):
93-
return _connexion.g.get('correlation_id', None)
93+
try:
94+
return _connexion.g.get('correlation_id', None)
95+
except:
96+
return None
9497

9598
def get_protocol(self, request):
9699
return request.environ.get('SERVER_PROTOCOL')

json_logging/framework/flask/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ def set_correlation_id(self, request_, value):
8686
_flask.g.correlation_id = value
8787

8888
def get_correlation_id_in_request_context(self, request):
89-
return _flask.g.get('correlation_id', None)
89+
try:
90+
return _flask.g.get('correlation_id', None)
91+
except:
92+
return None
9093

9194
def get_protocol(self, request):
9295
return request.environ.get('SERVER_PROTOCOL')

json_logging/framework/quart/__init__.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ def set_correlation_id(self, request_, value):
9191
_quart.g.correlation_id = value
9292

9393
def get_correlation_id_in_request_context(self, request):
94-
return _quart.g.get('correlation_id', None)
94+
try:
95+
return _quart.g.get('correlation_id', None)
96+
except:
97+
return None
9598

9699
def get_protocol(self, request):
97100
return request.scheme

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="json-logging",
15-
version='1.2.8',
15+
version='1.2.9',
1616
packages=find_packages(exclude=['contrib', 'docs', 'tests*', 'example', 'dist', 'build']),
1717
license='Apache License 2.0',
1818
description="JSON Python Logging",

0 commit comments

Comments
 (0)