From a7f73dd096e02320b44b8819e44189ffbaf406a5 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 1 Jul 2022 11:45:06 +0300 Subject: py: Add Python logging category Add Python logging category, and use it in handleRequestCompleted(). Signed-off-by: Tomi Valkeinen Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/py/libcamera/py_main.cpp | 12 ++++++++++-- src/py/libcamera/py_main.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/py/libcamera/py_main.h (limited to 'src/py') diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index 505cc3dc..4b698f77 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -5,6 +5,8 @@ * Python bindings */ +#include "py_main.h" + #include #include #include @@ -23,6 +25,12 @@ namespace py = pybind11; using namespace libcamera; +namespace libcamera { + +LOG_DEFINE_CATEGORY(Python) + +} + template static py::object valueOrTuple(const ControlValue &cv) { @@ -120,10 +128,10 @@ static void handleRequestCompleted(Request *req) size_t s = write(gEventfd, &v, 8); /* * We should never fail, and have no simple means to manage the error, - * so let's use LOG(Fatal). + * so let's log a fatal error. */ if (s != 8) - LOG(Fatal) << "Unable to write to eventfd"; + LOG(Python, Fatal) << "Unable to write to eventfd"; } void init_py_enums(py::module &m); diff --git a/src/py/libcamera/py_main.h b/src/py/libcamera/py_main.h new file mode 100644 index 00000000..5bb5f2d1 --- /dev/null +++ b/src/py/libcamera/py_main.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Tomi Valkeinen + */ + +#pragma once + +#include + +namespace libcamera { + +LOG_DECLARE_CATEGORY(Python) + +} -- cgit v1.2.1