Skip to content

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

@exhuma

Description

@exhuma

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions