Skip to content

Commit

Permalink
Merge pull request Netflix#2793 from castrapel/json_logging
Browse files Browse the repository at this point in the history
Add support for JSON logging
  • Loading branch information
castrapel committed May 17, 2019
2 parents 37e5857 + 4fac726 commit 3c6799d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
7 changes: 7 additions & 0 deletions lemur/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import imp
import errno
import pkg_resources
import socket

from logging import Formatter, StreamHandler
from logging.handlers import RotatingFileHandler

from flask import Flask
import logmatic

from lemur.certificates.hooks import activate_debug_dump
from lemur.common.health import mod as health
Expand Down Expand Up @@ -172,6 +174,11 @@ def configure_logging(app):
)
)

if app.config.get("LOG_JSON", False):
handler.setFormatter(
logmatic.JsonFormatter(extra={"hostname": socket.gethostname()})
)

handler.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
app.logger.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
app.logger.addHandler(handler)
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ twine==1.13.0
urllib3==1.25.2 # via requests
virtualenv==16.6.0 # via pre-commit
webencodings==0.5.1 # via bleach
zipp==0.5.0 # via importlib-metadata
zipp==0.5.1 # via importlib-metadata
6 changes: 4 additions & 2 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ babel==2.6.0 # via sphinx
bcrypt==3.1.6
billiard==3.6.0.0
blinker==1.4
boto3==1.9.149
botocore==1.12.149
boto3==1.9.150
botocore==1.12.150
celery[redis]==4.3.0
certifi==2019.3.9
certsrv==2.1.1
Expand Down Expand Up @@ -54,6 +54,7 @@ josepy==1.1.0
jsonlines==1.2.0
kombu==4.5.0
lockfile==0.12.2
logmatic-python==0.1.7
mako==1.0.10
markupsafe==1.1.1
marshmallow-sqlalchemy==0.16.3
Expand All @@ -77,6 +78,7 @@ pyparsing==2.4.0 # via packaging
pyrfc3339==1.1
python-dateutil==2.8.0
python-editor==1.0.4
python-json-logger==0.1.11
pytz==2019.1
pyyaml==5.1
raven[flask]==6.10.0
Expand Down
8 changes: 4 additions & 4 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ aws-sam-translator==1.11.0 # via cfn-lint
aws-xray-sdk==2.4.2 # via moto
bandit==1.6.0
black==19.3b0
boto3==1.9.149 # via aws-sam-translator, moto
boto3==1.9.150 # via aws-sam-translator, moto
boto==2.49.0 # via moto
botocore==1.12.149 # via aws-xray-sdk, boto3, moto, s3transfer
botocore==1.12.150 # via aws-xray-sdk, boto3, moto, s3transfer
certifi==2019.3.9 # via requests
cffi==1.12.3 # via cryptography
cfn-lint==0.20.2 # via moto
cfn-lint==0.20.3 # via moto
chardet==3.0.4 # via requests
click==7.0 # via black, flask
coverage==4.5.3
Expand Down Expand Up @@ -61,7 +61,7 @@ python-jose==3.0.1 # via moto
pytz==2019.1 # via moto
pyyaml==5.1
requests-mock==1.6.0
requests==2.22.0 # via cfn-lint, docker, moto, requests-mock, responses
requests==2.21.0 # via cfn-lint, docker, moto, requests-mock, responses
responses==0.10.6 # via moto
rsa==4.0 # via python-jose
s3transfer==0.2.0 # via boto3
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ inflection
jinja2
kombu
lockfile
logmatic-python
marshmallow-sqlalchemy
marshmallow
ndg-httpsclient
Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ asyncpool==1.0
bcrypt==3.1.6 # via flask-bcrypt, paramiko
billiard==3.6.0.0 # via celery
blinker==1.4 # via flask-mail, flask-principal, raven
boto3==1.9.149
botocore==1.12.149
boto3==1.9.150
botocore==1.12.150
celery[redis]==4.3.0
certifi==2019.3.9
certsrv==2.1.1
Expand Down Expand Up @@ -51,6 +51,7 @@ josepy==1.1.0 # via acme
jsonlines==1.2.0 # via cloudflare
kombu==4.5.0
lockfile==0.12.2
logmatic-python==0.1.7
mako==1.0.10 # via alembic
markupsafe==1.1.1 # via jinja2, mako
marshmallow-sqlalchemy==0.16.3
Expand All @@ -71,6 +72,7 @@ pyopenssl==19.0.0
pyrfc3339==1.1 # via acme
python-dateutil==2.8.0 # via alembic, arrow, botocore
python-editor==1.0.4 # via alembic
python-json-logger==0.1.11 # via logmatic-python
python-ldap==3.2.0
pytz==2019.1 # via acme, celery, flask-restful, pyrfc3339
pyyaml==5.1
Expand Down

0 comments on commit 3c6799d

Please sign in to comment.