Skip to content

Commit

Permalink
re fix #61 Using root logger + flask outside of flask request context…
Browse files Browse the repository at this point in the history
… throws RuntimeError
  • Loading branch information
Bob Bui committed Oct 16, 2020
1 parent d9171fa commit 926bfae
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ 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
## 1.2.10 - 2020-10-15
- re fix #61 Using root logger + flask outside of flask request context throws RuntimeError

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

## 1.2.8 - 2020-08-27
Expand Down
12 changes: 9 additions & 3 deletions json_logging/framework/connexion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,18 @@ def get_remote_user(self, request):
return json_logging.EMPTY_VALUE

def get_http_header(self, request, header_name, default=None):
if header_name in request.headers:
return request.headers.get(header_name)
try:
if header_name in request.headers:
return request.headers.get(header_name)
except:
pass
return default

def set_correlation_id(self, request_, value):
_connexion.g.correlation_id = value
try:
_connexion.g.correlation_id = value
except:
pass

def get_correlation_id_in_request_context(self, request):
try:
Expand Down
12 changes: 9 additions & 3 deletions json_logging/framework/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ def get_remote_user(self, request):
return json_logging.EMPTY_VALUE

def get_http_header(self, request, header_name, default=None):
if header_name in request.headers:
return request.headers.get(header_name)
try:
if header_name in request.headers:
return request.headers.get(header_name)
except:
pass
return default

def set_correlation_id(self, request_, value):
_flask.g.correlation_id = value
try:
_flask.g.correlation_id = value
except:
pass

def get_correlation_id_in_request_context(self, request):
try:
Expand Down
12 changes: 9 additions & 3 deletions json_logging/framework/quart/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ def get_remote_user(self, request):
return json_logging.EMPTY_VALUE

def get_http_header(self, request, header_name, default=None):
if header_name in request.headers:
return request.headers.get(header_name)
try:
if header_name in request.headers:
return request.headers.get(header_name)
except:
pass
return default

def set_correlation_id(self, request_, value):
_quart.g.correlation_id = value
try:
_quart.g.correlation_id = value
except:
pass

def get_correlation_id_in_request_context(self, request):
try:
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.9',
version='1.2.10',
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 926bfae

Please sign in to comment.