Move to kernel style SPDX license identifiers
[lttng-ust.git] / python-lttngust / lttngust / loghandler.py
1 # -*- coding: utf-8 -*-
2 #
3 # SPDX-License-Identifier: LGPL-2.1-only
4 #
5 # Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
6 # Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
7
8 from __future__ import unicode_literals
9 import logging
10 import ctypes
11
12
13 class _Handler(logging.Handler):
14 _LIB_NAME = 'liblttng-ust-python-agent.so.0'
15
16 def __init__(self):
17 super(self.__class__, self).__init__(level=logging.NOTSET)
18 self.setFormatter(logging.Formatter('%(asctime)s'))
19
20 # will raise if library is not found: caller should catch
21 self.agent_lib = ctypes.cdll.LoadLibrary(_Handler._LIB_NAME)
22
23 def emit(self, record):
24 self.agent_lib.py_tracepoint(self.format(record).encode(),
25 record.getMessage().encode(),
26 record.name.encode(),
27 record.funcName.encode(),
28 record.lineno, record.levelno,
29 record.thread,
30 record.threadName.encode())
This page took 0.029975 seconds and 4 git commands to generate.