Move to kernel style SPDX license identifiers
[lttng-ust.git] / python-lttngust / lttngust / loghandler.py
CommitLineData
de4dee04
PP
1# -*- coding: utf-8 -*-
2#
c0c0989a 3# SPDX-License-Identifier: LGPL-2.1-only
de4dee04 4#
c0c0989a
MJ
5# Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
6# Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
de4dee04
PP
7
8from __future__ import unicode_literals
9import logging
10import ctypes
11
12
13class _Handler(logging.Handler):
00ee1adf 14 _LIB_NAME = 'liblttng-ust-python-agent.so.0'
de4dee04
PP
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.025343 seconds and 4 git commands to generate.