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

Allow "tags" to be specified in "extra" for log messages. #67

Open
exhuma opened this issue Mar 24, 2017 · 0 comments
Open

Allow "tags" to be specified in "extra" for log messages. #67

exhuma opened this issue Mar 24, 2017 · 0 comments

Comments

@exhuma
Copy link

exhuma commented Mar 24, 2017

I have an application which needs to send messages with different tags to logstash. The tags are used to classify messages and change over runtime. It seems wasteful to me to generate a new handler instance just to support tags.

For one execution I expect to be in the tens for tags (so not that many). But I can't say from the beginning which tags will be emitted so sending a message looks like this currently:

def send_message(tags, message):
    handler = TCPLogstashHandler([...], tags=tags)
    LOG.addHandler(handler)
    LOG.info(message)
    LOG.removeHandler(handler)

Having the tags exposed in the via the "extra" attribute would allow me to write this:

def send_message(tags, message):
    LOG.info(message, extra={'tags': tags}

which would even make the send_message function redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant