Skip to content

subclassing for build_message #38

Description

@znd4

Is Rfc5424SysLogHandler.build_msg meant to be thought of as a public method, or is it an implementation detail?

We've got an http endpoint that accepts rfc5424-encoded messages. I've got everything working with something like this:

class HttpRfcHandler(Rfc5424SysLogHandler):
    """Extend Rfc5424SysLogHandler to support http:// addresses"""
    def emit(self, record):
        try:
            msg = self.build_msg(record)
            response = requests.post(url=self.address, data=msg)
            response.raise_for_status()
        except Exception:
            self.handleError(record)

(not encluding some stuff that's specific to our environment).

Am I okay treating build_msg like it's part of the public API in this way?

Also, since the urlparse logic for checking the scheme of self.address is pretty simple, would built-in support for this use-case be worth adding in a PR? I don't know how common it is.

An alternative would be to add a section to the docs talking about this subclassing approach, which I guess would let people write to whatever sink they want (object storage, message queues, etc.)

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