Skip to content
New issue

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

By clicking “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? Sign in to your account

Add ability to override name in log record #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cid/log.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import logging

from django.conf import settings

from cid.locals import get_cid


class CidContextFilter(logging.Filter):

def filter(self, record):
record.cid = get_cid()
setattr(record, getattr(settings, 'CID_LOG_RECORD_NAME', 'cid'), get_cid())
return True