Example #1
0
    def parse_netstr(self, data):
        """ Parse tnetstrings datagram sent by skylog """
        try:
            msg, rest = tnetstrings.parse(data)
            if rest:
                self.log.warning("netstr parsing leftover: %r", rest)
                self.log.debug("failed tnetstring: [%i] %r", len(data), data)
            return msg

        except Exception, e:
            if self.log_parsing_errors:
                self.log.warning("netstr parsing error: %s", e)
                self.log.debug("failed tnetstring: [%i] %r", len(data), data)
            return None
Example #2
0
    def parse_netstr (self, data):
        """ Parse tnetstrings datagram sent by skylog """
        try:
            msg, rest = tnetstrings.parse (data)
            if rest:
                self.log.warning ("netstr parsing leftover: %r", rest)
                self.log.debug ("failed tnetstring: [%i] %r", len(data), data)
            return msg

        except Exception, e:
            if self.log_parsing_errors:
                self.log.warning ("netstr parsing error: %s", e)
                self.log.debug ("failed tnetstring: [%i] %r", len(data), data)
            return None
Example #3
0
    def parse_netstr (self, data):
        """ Parse netstrings datagram sent by pg_logforward """
        try:
            keys = [ "elevel", "sqlerrcode", "username", "database",
                    "remotehost", "funcname", "message", "detail",
                    "hint", "context", "debug_query_string" ]
            pos = 0
            res = {}
            while data:
                res[keys[pos]], data = tnetstrings.parse (data)
                pos += 1
            res['elevel'] = int(res['elevel'])
            res['elevel_text'] = pg_elevels_itoa[res['elevel']]
            res['sqlerrcode'] = int(res['sqlerrcode'])
            return res

        except Exception, e:
            if self.log_parsing_errors:
                self.log.warning ("netstr parsing error: %s", e)
                self.log.debug ("failed netstring: {%s} [%i] %r", keys[pos], len(data), data)
            return None
Example #4
0
    def parse_netstr(self, data):
        """ Parse netstrings datagram sent by pg_logforward """
        try:
            keys = [
                "elevel", "sqlerrcode", "username", "database", "remotehost",
                "funcname", "message", "detail", "hint", "context",
                "debug_query_string"
            ]
            pos = 0
            res = {}
            while data:
                res[keys[pos]], data = tnetstrings.parse(data)
                pos += 1
            res['elevel'] = int(res['elevel'])
            res['elevel_text'] = pg_elevels_itoa[res['elevel']]
            res['sqlerrcode'] = int(res['sqlerrcode'])
            return res

        except Exception, e:
            if self.log_parsing_errors:
                self.log.warning("netstr parsing error: %s", e)
                self.log.debug("failed netstring: {%s} [%i] %r", keys[pos],
                               len(data), data)
            return None