Patch Detail
Show a patch.
GET /api/patches/1651/?format=api
{ "id": 1651, "url": "https://patchwork.libcamera.org/api/patches/1651/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1651/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190711093632.22133-1-paul.elder@ideasonboard.com>", "date": "2019-07-11T09:36:31", "name": "[libcamera-devel,1/2] libcamera: logging: add logging API for applications", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "092f571ce0db1e1aeefb4c74824b58ef7ee3ec95", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1651/mbox/", "series": [ { "id": 416, "url": "https://patchwork.libcamera.org/api/series/416/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=416", "date": "2019-07-11T09:36:31", "name": "[libcamera-devel,1/2] libcamera: logging: add logging API for applications", "version": 1, "mbox": "https://patchwork.libcamera.org/series/416/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1651/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1651/checks/", "tags": {}, "headers": { "Return-Path": "<paul.elder@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ABC2D61572\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Jul 2019 11:36:40 +0200 (CEST)", "from neptunite.amanokami.net (softbank126163157105.bbtec.net\n\t[126.163.157.105])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3675A31C;\n\tThu, 11 Jul 2019 11:36:38 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562837800;\n\tbh=SOVn2LJVio2mtMOuZQCoF1zNkG3fVGFZUyc7t99RZQw=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=bReKmfCwdqOJO9cuV8ydGnLENfIrZOCCOOCdvKR3VIOulMLKnbz28PvKjhJX/Chi7\n\tdrkfTScA4E4BdmMEg4mtIpmeCZeKkY26ZVTJyEY6UrYuqkBivEo1+/QTR2eEf2VOl2\n\taNdR8qPUMznepV0QwfwWxdSyCrMTt41jl9KF2oXc=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 11 Jul 2019 18:36:31 +0900", "Message-Id": "<20190711093632.22133-1-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.20.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: logging: add logging API\n\tfor applications", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Thu, 11 Jul 2019 09:36:40 -0000" }, "content": "Currently the log file and the log level can only be set via environment\nvariables, but applications may also want to set the log file and the\nlog level at run time. Provide an API for this.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n include/libcamera/logging.h | 17 +++++++++++++++++\n include/libcamera/meson.build | 1 +\n src/libcamera/log.cpp | 32 ++++++++++++++++++++++++++++++++\n 3 files changed, 50 insertions(+)\n create mode 100644 include/libcamera/logging.h", "diff": "diff --git a/include/libcamera/logging.h b/include/libcamera/logging.h\nnew file mode 100644\nindex 0000000..47c5e49\n--- /dev/null\n+++ b/include/libcamera/logging.h\n@@ -0,0 +1,17 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * log.h - Logging infrastructure\n+ */\n+#ifndef __LIBCAMERA_LOGGING_H__\n+#define __LIBCAMERA_LOGGING_H__\n+\n+namespace libcamera {\n+\n+void logSetFile(const char *file);\n+void logSetLevel(const char *category, const char *level);\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_LOGGING_H__ */\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 972513f..920eb5f 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -9,6 +9,7 @@ libcamera_api = files([\n 'geometry.h',\n 'ipa/ipa_interface.h',\n 'ipa/ipa_module_info.h',\n+ 'logging.h',\n 'object.h',\n 'request.h',\n 'signal.h',\ndiff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp\nindex 0ba276e..e322b8f 100644\n--- a/src/libcamera/log.cpp\n+++ b/src/libcamera/log.cpp\n@@ -69,6 +69,9 @@ private:\n \tvoid parseLogLevels();\n \tstatic LogSeverity parseLogLevel(const std::string &level);\n \n+\tfriend void logSetFile(const char *file);\n+\tfriend void logSetLevel(const char *category, const char *level);\n+\n \tfriend LogCategory;\n \tvoid registerCategory(LogCategory *category);\n \tvoid unregisterCategory(LogCategory *category);\n@@ -80,6 +83,35 @@ private:\n \tstd::ostream *output_;\n };\n \n+void logSetFile(const char *file)\n+{\n+\tif (std::string(file).empty())\n+\t\treturn;\n+\n+\tLogger *logger = Logger::instance();\n+\tstd::ofstream &file_ = logger->file_;\n+\tfile_.close();\n+\tfile_.open(file);\n+\tif (file_.good())\n+\t\tlogger->output_ = &file_;\n+}\n+\n+void logSetLevel(const char *category, const char *level)\n+{\n+\tstd::string cat(category);\n+\tstd::string lev(level);\n+\n+\t/* Both the category and the level must be specified. */\n+\tif (cat.empty() || lev.empty())\n+\t\treturn;\n+\n+\tLogSeverity severity = Logger::parseLogLevel(lev);\n+\tif (severity == LogInvalid)\n+\t\treturn;\n+\n+\tLogger::instance()->levels_.push_back({ cat, severity });\n+}\n+\n /**\n * \\brief Retrieve the logger instance\n *\n", "prefixes": [ "libcamera-devel", "1/2" ] }