Fix: specify SONAME in python-lttngust LoadLibrary
[lttng-ust.git] / python-lttngust / lttngust / loghandler.py
CommitLineData
de4dee04
PP
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2015 - Philippe Proulx <pproulx@efficios.com>
4# Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
5#
6# This library is free software; you can redistribute it and/or modify it under
7# the terms of the GNU Lesser General Public License as published by the Free
8# Software Foundation; version 2.1 of the License.
9#
10# This library is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13# details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this library; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19from __future__ import unicode_literals
20import logging
21import ctypes
22
23
24class _Handler(logging.Handler):
00ee1adf 25 _LIB_NAME = 'liblttng-ust-python-agent.so.0'
de4dee04
PP
26
27 def __init__(self):
28 super(self.__class__, self).__init__(level=logging.NOTSET)
29 self.setFormatter(logging.Formatter('%(asctime)s'))
30
31 # will raise if library is not found: caller should catch
32 self.agent_lib = ctypes.cdll.LoadLibrary(_Handler._LIB_NAME)
33
34 def emit(self, record):
35 self.agent_lib.py_tracepoint(self.format(record).encode(),
36 record.getMessage().encode(),
37 record.name.encode(),
38 record.funcName.encode(),
39 record.lineno, record.levelno,
40 record.thread,
41 record.threadName.encode())
This page took 0.024619 seconds and 4 git commands to generate.