From patchwork Mon Oct 14 08:13:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21610 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 61C42C32F4 for ; Mon, 14 Oct 2024 08:17:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 953486537F; Mon, 14 Oct 2024 10:17:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QsIxnyRV"; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4DCCE65369 for ; Mon, 14 Oct 2024 10:17:46 +0200 (CEST) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-20c803787abso26239795ad.0 for ; Mon, 14 Oct 2024 01:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728893864; x=1729498664; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rxwiUBIEAfDRAwGvEPZptJCNsMniO4pLRE57r3qaf0E=; b=QsIxnyRVcNtxjunYaTfoTOKY4YZdtvJ/AI/idVOkxM6mGl1SbDErZ5/MlOHoVYfKMP ffII0Mz4KtqMUUwkHjjvr97D+/XXhirwFaW3pQdLIiHS0E6vQ1ApSIZJhFUG5GUXqx9M iP3r5+c6WZQhAXHscsLJkafaFnIUeq2SdS5sk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728893864; x=1729498664; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rxwiUBIEAfDRAwGvEPZptJCNsMniO4pLRE57r3qaf0E=; b=WpB8s2Htrpq6gcuFS8Qq23E9jA4qa+3A3HBowAOZluj+yxtL8weUB+jYdtXoa1vyZa AwWNLZud8koW51abU5ZYqWZGlqlcLMn8QRIk92oaUrBgprSTxu+0bI05e0N2TnILeFKz J/y4AfJoF4T7ebIbixPuxsg72BFxXMULLdxnOh0nMO7eKt8TTzeEwtAs9vRViltcMteD 1DZDINYsojgVFJyxsoFT2udY6R+dyPA6njGjx+Hmx6woR5HECDaxBTeMpiJDvqv2yaTz y55BRU7tp5k4+PA45gXJIZE39seH8SxGzx5JlZZrmR+rWxK7j67DJMkCkq1tp3o7ehDv O7ZA== X-Gm-Message-State: AOJu0YxfJGhGbMZBBb1YurZG+4lwhA9i+7OANjL3fF/vw+EUiLczLk8g ZMGZ2t5R3p/Cl9HkpXhpraKVzJCIBmigIRO8BLcAvBo5RIomQJ/TwjMqtBUBTP0FRSuuD36Sp4w = X-Google-Smtp-Source: AGHT+IE9K35hC/DljqnGq8Vz9T4+TMC7TVxiydfejnsanpS5/Cauzw+jmsf50ezxNGBeWivn8Nvq9A== X-Received: by 2002:a17:903:244d:b0:20c:da7c:6e8c with SMTP id d9443c01a7336-20cda7c7273mr66249985ad.3.1728893864453; Mon, 14 Oct 2024 01:17:44 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (199.211.81.34.bc.googleusercontent.com. [34.81.211.199]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c21da63sm61077735ad.235.2024.10.14.01.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 01:17:44 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Han-Lin Chen , Harvey Yang Subject: [PATCH 1/2] libcamera: add OS_CHROMEOS when the android_platform is cros Date: Mon, 14 Oct 2024 08:13:54 +0000 Message-ID: <20241014081738.772258-2-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241014081738.772258-1-chenghaoyang@chromium.org> References: <20241014081738.772258-1-chenghaoyang@chromium.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Han-Lin Chen Add OS_CHROMEOS when the android_platform is cros. Signed-off-by: Han-Lin Chen Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index 63e45465d..e28fa8599 100644 --- a/meson.build +++ b/meson.build @@ -184,6 +184,10 @@ if cc.has_argument('-Wno-c99-designator') ] endif +if get_option('android_platform') == 'cros' + common_arguments += ['-DOS_CHROMEOS'] +endif + c_arguments += common_arguments cpp_arguments += common_arguments From patchwork Mon Oct 14 08:13:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21611 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id BD0F8C32F4 for ; Mon, 14 Oct 2024 08:17:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4598E65381; Mon, 14 Oct 2024 10:17:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="AB1Ac9aY"; dkim-atps=neutral Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F9BF65369 for ; Mon, 14 Oct 2024 10:17:47 +0200 (CEST) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-20cd76c513cso7498225ad.3 for ; Mon, 14 Oct 2024 01:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728893866; x=1729498666; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BEoLH5qkWhGczJGaMIosPtFECkIOlbkqBdYQmdDgFGg=; b=AB1Ac9aYC/qOl4G0Ylgxrx7ULS1liXcjF5EuIb9kg3MyNYrsp/QVUoVsrac37J+aG4 TgvuCcqEZZJRhbFsZZG5ew09OEuw7z7j2YzK/yfe6rK5+wyHIkH2qXRaO5tJ4XsOJLsM fb8eXOs3WzU0rEEuDzyzKuX7R6VnYrdOdsXDw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728893866; x=1729498666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BEoLH5qkWhGczJGaMIosPtFECkIOlbkqBdYQmdDgFGg=; b=F9gQSCs9iH139p1ddteaCZqWBqCiaPbROXnPNXBKsvq1nRmrFkwmrecn20IOFJQENO bPrD17asi3LyBLAxDNtmaKif7VSEe+kr9+3VGVTePkLHEnRSVB6S1e0TjkdEje3dADp+ ssB7JqdiYhMWKrBJOSTPOlMgOC4EY+O7K7mRaPUfd5WIeDN1ZD0949pc985IOv91uSwr /Iyj1A21kogJQFOqPQ3y9gIkozQDTApEhhqXQm4wFxH7zGyUPlo3WPExndFllKyrPB0K +6Rtih4+Gd9+OeiPxdRFtlM/2EfUpKUfUDGuViF0asY5wWa4azTqt0byxYZoKi0N3xWv e9Kw== X-Gm-Message-State: AOJu0Yx/RfzPa+TSZqWQRWgxMu7SpifRZTWEyCLenHLGxD4BszJQ9TgV /qEuGIoRBZGSEMufBZ1Dg0ScholbQZLKJg9kSdPqhrlgZ9m3kLmem7EoU64XZKGrew03dHxzVSs = X-Google-Smtp-Source: AGHT+IGvhw4RZ7TEyfcOYAGpHnvC7CbuIXnEjTe/yQHhLOQfh6MktrVUablF2tg0BIbFlq7B+16c7Q== X-Received: by 2002:a17:902:ea11:b0:20c:da98:d752 with SMTP id d9443c01a7336-20cda98da15mr58335505ad.16.1728893865988; Mon, 14 Oct 2024 01:17:45 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (199.211.81.34.bc.googleusercontent.com. [34.81.211.199]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c21da63sm61077735ad.235.2024.10.14.01.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 01:17:45 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Han-Lin Chen , Harvey Yang Subject: [PATCH 2/2] libcamera: log: add logTargetCros for ChromeOS logs Date: Mon, 14 Oct 2024 08:13:55 +0000 Message-ID: <20241014081738.772258-3-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241014081738.772258-1-chenghaoyang@chromium.org> References: <20241014081738.772258-1-chenghaoyang@chromium.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Han-Lin Chen ChromeOS logging requires that the logs export to both syslog and std::cerr. Add a logTargetCros for the specific case. Signed-off-by: Han-Lin Chen Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- include/libcamera/logging.h | 1 + src/libcamera/base/log.cpp | 61 +++++++++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/include/libcamera/logging.h b/include/libcamera/logging.h index e1c6341ce..b88acf23b 100644 --- a/include/libcamera/logging.h +++ b/include/libcamera/logging.h @@ -16,6 +16,7 @@ enum LoggingTarget { LoggingTargetSyslog, LoggingTargetFile, LoggingTargetStream, + LoggingTargetCros, }; int logSetFile(const char *path, bool color = false); diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 3a656b8f0..930e2329e 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -107,6 +107,7 @@ class LogOutput public: LogOutput(const char *path, bool color); LogOutput(std::ostream *stream, bool color); + LogOutput(bool color); LogOutput(); ~LogOutput(); @@ -144,6 +145,19 @@ LogOutput::LogOutput(std::ostream *stream, bool color) { } +/** + * \brief Construct a log output to both std:err and syslog + * \param[in] color True to output colored messages + * + * Currently this is only needed for CrOS. Therefore, the target is set to + * `LoggingTargetCros`. + */ +LogOutput::LogOutput(bool color) + : stream_(&std::cerr), target_(LoggingTargetCros), color_(color) +{ + openlog("libcamera", LOG_PID, 0); +} + /** * \brief Construct a log output to syslog */ @@ -160,6 +174,7 @@ LogOutput::~LogOutput() delete stream_; break; case LoggingTargetSyslog: + case LoggingTargetCros: closelog(); break; default: @@ -230,17 +245,26 @@ void LogOutput::write(const LogMessage &msg) severityColor = kColorBrightWhite; } + bool toStream = false; + bool toSyslog = false; + switch (target_) { case LoggingTargetSyslog: - str = std::string(log_severity_name(severity)) + " " - + msg.category().name() + " " + msg.fileInfo() + " "; - if (!msg.prefix().empty()) - str += msg.prefix() + ": "; - str += msg.msg(); - writeSyslog(severity, str); + toSyslog = true; break; case LoggingTargetStream: case LoggingTargetFile: + toStream = true; + break; + case LoggingTargetCros: + toSyslog = true; + toStream = true; + break; + default: + break; + } + + if (toStream) { str = "[" + utils::time_point_to_string(msg.timestamp()) + "] [" + std::to_string(Thread::currentId()) + "] " + severityColor + log_severity_name(severity) + " " @@ -250,9 +274,15 @@ void LogOutput::write(const LogMessage &msg) str += prefixColor + msg.prefix() + ": "; str += resetColor + msg.msg(); writeStream(str); - break; - default: - break; + } + + if (toSyslog) { + str = std::string(log_severity_name(severity)) + " " + + msg.category().name() + " " + msg.fileInfo() + " "; + if (!msg.prefix().empty()) + str += msg.prefix() + ": "; + str += msg.msg(); + writeSyslog(severity, str); } } @@ -270,6 +300,10 @@ void LogOutput::write(const std::string &str) case LoggingTargetFile: writeStream(str); break; + case LoggingTargetCros: + writeSyslog(LogDebug, str); + writeStream(str); + break; default: break; } @@ -549,6 +583,9 @@ int Logger::logSetTarget(enum LoggingTarget target) case LoggingTargetNone: std::atomic_store(&output_, std::shared_ptr()); break; + case LoggingTargetCros: + std::atomic_store(&output_, std::make_shared(true)); + break; default: return -EINVAL; } @@ -586,6 +623,12 @@ void Logger::logSetLevel(const char *category, const char *level) */ Logger::Logger() { +#if defined(OS_CHROMEOS) + logSetTarget(LoggingTargetCros); + parseLogLevels(); + return; +#endif + bool color = !utils::secure_getenv("LIBCAMERA_LOG_NO_COLOR"); logSetStream(&std::cerr, color);