コード例 #1
0
ファイル: tracer.py プロジェクト: nshalman/python-usdt
 def __init__(self, func):
     self.func = func
     probename = func.__name__
     self.entry_probe = Probe(probename, "entry", ["char *"])
     self.return_probe = Probe(probename, "return", ["char *"])
     self.provider = Provider("python-fbt", "fbt")
     self.provider.add_probe(self.entry_probe)
     self.provider.add_probe(self.return_probe)
     self.provider.enable()
コード例 #2
0
ファイル: log.py プロジェクト: nshalman/python-usdt
    def __init__(self):
        logging.Handler.__init__(self)

        self.provider = Provider("python", "dtrace-logger")

        self.probes = {}
        for key in _DESC.keys():
            self.probes[key] = Probe("logging", _DESC[key], ["int", "char *"])
            self.provider.add_probe(self.probes[key])
        self.provider.enable()
コード例 #3
0
ファイル: tracer.py プロジェクト: steinbro/python-usdt
 def __init__(self, func):
     self.func = func
     probename = func.__name__
     self.entry_probe = Probe(probename, "entry", ["char *"])
     self.return_probe = Probe(probename, "return", ["char *"])
     self.provider = Provider("python-fbt", "fbt")
     self.provider.add_probe(self.entry_probe)
     self.provider.add_probe(self.return_probe)
     self.provider.enable()
コード例 #4
0
ファイル: log.py プロジェクト: steinbro/python-usdt
    def __init__(self):
        logging.Handler.__init__(self)

        self.provider = Provider("python", "dtrace-logger")

        self.probes = {}
        for key in _DESC.keys():
            self.probes[key] = Probe("logging", _DESC[key], ["int", "char *"])
            self.provider.add_probe(self.probes[key])
        self.provider.enable()
コード例 #5
0
ファイル: log.py プロジェクト: steinbro/python-usdt
class DtraceHandler(logging.Handler):
    """ Handler to fire USDT probes with log messages """
    def __init__(self):
        logging.Handler.__init__(self)

        self.provider = Provider("python", "dtrace-logger")

        self.probes = {}
        for key in _DESC.keys():
            self.probes[key] = Probe("logging", _DESC[key], ["int", "char *"])
            self.provider.add_probe(self.probes[key])
        self.provider.enable()

    def emit(self, record):
        """ Fire the appropriate USDT probe for this record's log level """
        probe = None
        for level in _LEVELS:
            if record.levelno >= level:
                probe = self.probes[level]
                break
        if not probe:
            probe = self.probes[logging.NOTSET]
        probe.fire([record.levelno, self.format(record)])
コード例 #6
0
ファイル: log.py プロジェクト: nshalman/python-usdt
class DtraceHandler(logging.Handler):
    """ Handler to fire USDT probes with log messages """
    def __init__(self):
        logging.Handler.__init__(self)

        self.provider = Provider("python", "dtrace-logger")

        self.probes = {}
        for key in _DESC.keys():
            self.probes[key] = Probe("logging", _DESC[key], ["int", "char *"])
            self.provider.add_probe(self.probes[key])
        self.provider.enable()

    def emit(self, record):
        """ Fire the appropriate USDT probe for this record's log level """
        probe = None
        for level in _LEVELS:
            if record.levelno >= level:
                probe = self.probes[level]
                break
        if not probe:
            probe = self.probes[logging.NOTSET]
        probe.fire([record.levelno, self.format(record)])
コード例 #7
0
ファイル: tracer.py プロジェクト: steinbro/python-usdt
class fbt(object):
    """
    simple function boundary tracing decorator
    """
    def __init__(self, func):
        self.func = func
        probename = func.__name__
        self.entry_probe = Probe(probename, "entry", ["char *"])
        self.return_probe = Probe(probename, "return", ["char *"])
        self.provider = Provider("python-fbt", "fbt")
        self.provider.add_probe(self.entry_probe)
        self.provider.add_probe(self.return_probe)
        self.provider.enable()

    def __call__(self, *args):
        self.entry_probe.fire([", ".join([str(x) for x in args])])
        ret = self.func(*args)
        self.return_probe.fire([str(ret)])
        return ret

    def __get__(self, obj, objtype):
        """Support instance methods. (http://stackoverflow.com/a/3296318)"""
        return functools.partial(self.__call__, obj)
コード例 #8
0
ファイル: tracer.py プロジェクト: nshalman/python-usdt
class fbt(object):
    """
    simple function boundary tracing decorator
    """
    def __init__(self, func):
        self.func = func
        probename = func.__name__
        self.entry_probe = Probe(probename, "entry", ["char *"])
        self.return_probe = Probe(probename, "return", ["char *"])
        self.provider = Provider("python-fbt", "fbt")
        self.provider.add_probe(self.entry_probe)
        self.provider.add_probe(self.return_probe)
        self.provider.enable()

    def __call__(self, *args):
        self.entry_probe.fire([", ".join([str(x) for x in args])])
        ret = self.func(*args)
        self.return_probe.fire([str(ret)])
        return ret

    def __get__(self, obj, objtype):
        """Support instance methods. (http://stackoverflow.com/a/3296318)"""
        return functools.partial(self.__call__, obj)