How to use the pygelf.tcp.GelfTcpHandler function in pygelf

To help you get started, we’ve selected a few pygelf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keeprocking / pygelf / pygelf / tcp.py View on Github external
def __init__(self, host, port, debug=False, **kwargs):
        """
        Logging handler that transforms each record into GELF (graylog extended log format) and sends it over tcp.

        :param host: gelf tcp input host
        :param port: gelf tcp input port
        :param debug: include debug fields, e.g. line number, or not
        :param kwargs: additional fields that will be included in the log message, e.g. application name.
                       Each additional field should start with underscore, e.g. _app_name
        """

        super(GelfTcpHandler, self).__init__(host, port)
        self.additional_fields = kwargs
        self.debug = debug
        self.additional_fields.pop('_id', None)
github keeprocking / pygelf / pygelf / tls.py View on Github external
from pygelf.tcp import GelfTcpHandler
import ssl
import socket


class GelfTlsHandler(GelfTcpHandler):
    """
    TCP GELF logging handler with TLS support

    :param validate: if true, validate server certificate. In that case ca_certs are required.
    :param ca_certs: path to CA bundle file. For instance, on CentOS it would be '/etc/pki/tls/certs/ca-bundle.crt'
    """

    def __init__(self, validate=False, ca_certs=None, **kwargs):
        super(GelfTlsHandler, self).__init__(**kwargs)

        if validate and ca_certs is None:
            raise ValueError('CA bundle file path must be specified')

        self.ca_certs = ca_certs
        self.reqs = ssl.CERT_REQUIRED if validate else ssl.CERT_NONE