py: Add Python logging category
Add Python logging category, and use it in handleRequestCompleted(). Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
93629989a9
commit
a7f73dd096
2 changed files with 24 additions and 2 deletions
|
@ -5,6 +5,8 @@
|
||||||
* Python bindings
|
* Python bindings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "py_main.h"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
|
@ -23,6 +25,12 @@ namespace py = pybind11;
|
||||||
|
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
|
namespace libcamera {
|
||||||
|
|
||||||
|
LOG_DEFINE_CATEGORY(Python)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static py::object valueOrTuple(const ControlValue &cv)
|
static py::object valueOrTuple(const ControlValue &cv)
|
||||||
{
|
{
|
||||||
|
@ -120,10 +128,10 @@ static void handleRequestCompleted(Request *req)
|
||||||
size_t s = write(gEventfd, &v, 8);
|
size_t s = write(gEventfd, &v, 8);
|
||||||
/*
|
/*
|
||||||
* We should never fail, and have no simple means to manage the error,
|
* 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)
|
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);
|
void init_py_enums(py::module &m);
|
||||||
|
|
14
src/py/libcamera/py_main.h
Normal file
14
src/py/libcamera/py_main.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <libcamera/base/log.h>
|
||||||
|
|
||||||
|
namespace libcamera {
|
||||||
|
|
||||||
|
LOG_DECLARE_CATEGORY(Python)
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue