Skip to content

Commit

Permalink
pw_log_fuchsia: Create pw_log Fuchsia backend
Browse files Browse the repository at this point in the history
Change-Id: I3672318e535eb9e4a5edf343f79d0053c1d2da96
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/231052
Reviewed-by: Darren Chan <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
Reviewed-by: Ted Pudlik <[email protected]>
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Faraaz Sareshwala <[email protected]>
Pigweed-Auto-Submit: Ben Lawson <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
BenjaminLawson authored and CQ Bot Account committed Aug 27, 2024
1 parent 871fd5f commit 3dc3f1a
Show file tree
Hide file tree
Showing 13 changed files with 450 additions and 14 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ add_subdirectory(pw_json EXCLUDE_FROM_ALL)
add_subdirectory(pw_kvs EXCLUDE_FROM_ALL)
add_subdirectory(pw_log EXCLUDE_FROM_ALL)
add_subdirectory(pw_log_basic EXCLUDE_FROM_ALL)
add_subdirectory(pw_log_fuchsia EXCLUDE_FROM_ALL)
add_subdirectory(pw_log_null EXCLUDE_FROM_ALL)
add_subdirectory(pw_log_string EXCLUDE_FROM_ALL)
add_subdirectory(pw_log_tokenized EXCLUDE_FROM_ALL)
Expand Down
1 change: 1 addition & 0 deletions PIGWEED_MODULES
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pw_libcxx
pw_log
pw_log_android
pw_log_basic
pw_log_fuchsia
pw_log_null
pw_log_rpc
pw_log_string
Expand Down
36 changes: 22 additions & 14 deletions docs/module_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,6 @@
"C++20"
]
},
"pw_hex_dump": {
"tagline": "Handy hexdump utilities",
"status": "stable",
"languages": [
"C++17"
]
},
"pw_hdlc": {
"tagline": "Simple, robust, and efficient serial communication",
"status": "stable",
Expand All @@ -324,6 +317,13 @@
"TypeScript"
]
},
"pw_hex_dump": {
"tagline": "Handy hexdump utilities",
"status": "stable",
"languages": [
"C++17"
]
},
"pw_i2c": {
"tagline": "Cross-platform I2C API with interactive debugging",
"status": "stable",
Expand Down Expand Up @@ -393,6 +393,14 @@
"C++"
]
},
"pw_log_fuchsia": {
"tagline": "Fuchsia logging backend",
"status": "experimental",
"languages": [
"C",
"C++"
]
},
"pw_malloc": {
"tagline": "Replacement interface for standard libc dynamic memory operations",
"status": "stable",
Expand Down Expand Up @@ -437,20 +445,20 @@
"C++"
]
},
"pw_router": {
"tagline": "Transport-agnostic packet routing",
"status": "experimental",
"languages": [
"C++"
]
},
"pw_result": {
"tagline": "Error propagation primitives: value-or-error",
"status": "stable",
"languages": [
"C++17"
]
},
"pw_router": {
"tagline": "Transport-agnostic packet routing",
"status": "experimental",
"languages": [
"C++"
]
},
"pw_rpc": {
"tagline": "Efficient, low-code-size RPC system for embedded devices",
"status": "stable",
Expand Down
4 changes: 4 additions & 0 deletions pw_build/generated_pigweed_modules_lists.gni
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ declare_args() {
dir_pw_log = get_path_info("../pw_log", "abspath")
dir_pw_log_android = get_path_info("../pw_log_android", "abspath")
dir_pw_log_basic = get_path_info("../pw_log_basic", "abspath")
dir_pw_log_fuchsia = get_path_info("../pw_log_fuchsia", "abspath")
dir_pw_log_null = get_path_info("../pw_log_null", "abspath")
dir_pw_log_rpc = get_path_info("../pw_log_rpc", "abspath")
dir_pw_log_string = get_path_info("../pw_log_string", "abspath")
Expand Down Expand Up @@ -314,6 +315,7 @@ declare_args() {
dir_pw_log,
dir_pw_log_android,
dir_pw_log_basic,
dir_pw_log_fuchsia,
dir_pw_log_null,
dir_pw_log_rpc,
dir_pw_log_string,
Expand Down Expand Up @@ -493,6 +495,7 @@ declare_args() {
"$dir_pw_log:tests",
"$dir_pw_log_android:tests",
"$dir_pw_log_basic:tests",
"$dir_pw_log_fuchsia:tests",
"$dir_pw_log_null:tests",
"$dir_pw_log_rpc:tests",
"$dir_pw_log_string:tests",
Expand Down Expand Up @@ -672,6 +675,7 @@ declare_args() {
"$dir_pw_log:docs",
"$dir_pw_log_android:docs",
"$dir_pw_log_basic:docs",
"$dir_pw_log_fuchsia:docs",
"$dir_pw_log_null:docs",
"$dir_pw_log_rpc:docs",
"$dir_pw_log_string:docs",
Expand Down
1 change: 1 addition & 0 deletions pw_log/backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pw_log backends

Android <../pw_log_android/docs>
Basic <../pw_log_basic/docs>
Fuchsia <../pw_log_fuchsia/docs>
Null <../pw_log_null/docs>
RPC <../pw_log_rpc/docs>
String <../pw_log_string/docs>
Expand Down
48 changes: 48 additions & 0 deletions pw_log_fuchsia/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

cc_library(
name = "pw_log_fuchsia",
srcs = [
"log_fuchsia.cc",
],
hdrs = [
"public/pw_log_fuchsia/log_backend.h",
"public_overrides/pw_log_backend/log_backend.h",
],
includes = [
"public",
"public_overrides",
],
target_compatible_with = ["@platforms//os:fuchsia"],
deps = [
"@fuchsia_sdk//fidl/fuchsia.logger:fuchsia.logger_cpp",
"@fuchsia_sdk//pkg/async-cpp",
"@fuchsia_sdk//pkg/component_incoming_cpp",
"@fuchsia_sdk//pkg/syslog_structured_backend",
"@pigweed//pw_log:facade",
"@pigweed//pw_preprocessor",
"@pigweed//pw_string:builder",
],
)

# Bazel does not yet support building docs.
filegroup(
name = "docs",
srcs = ["docs.rst"],
)
35 changes: 35 additions & 0 deletions pw_log_fuchsia/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

import("//build_overrides/pigweed.gni")

import("$dir_pw_docgen/docs.gni")
import("$dir_pw_unit_test/test.gni")

pw_doc_group("docs") {
sources = [ "docs.rst" ]
}

pw_test_group("tests") {
}

# Satisfy source_is_in_build_files presubmit step
pw_source_set("satisfy_presubmit") {
sources = [
"log_fuchsia.cc",
"public/pw_log_fuchsia/log_backend.h",
"public_overrides/pw_log_backend/log_backend.h",
]
visibility = []
}
19 changes: 19 additions & 0 deletions pw_log_fuchsia/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)



# CMake does not yet support building docs.
3 changes: 3 additions & 0 deletions pw_log_fuchsia/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[email protected]
[email protected]
[email protected]
24 changes: 24 additions & 0 deletions pw_log_fuchsia/docs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. _module-pw_log_fuchsia:

==============
pw_log_fuchsia
==============
.. pigweed-module::
:name: pw_log_fuchsia

--------
Overview
--------
The ``pw_log_fuchsia`` module provides a ``PW_HANDLE_LOG`` backend for the
``pw_log`` module. The backend uses the ``fuchsia.logger.LogSink`` FIDL API
to send logs. Only Bazel is supported because the Fuchsia SDK only supports Bazel.

---
API
---
Before logging, ``pw::log_fuchsia::InitializeLogging(async_dispatcher_t*)`` must
be called to initialize the logging state.

Two log flags are supported to help with logging during tests:
``PW_LOG_FLAG_USE_PRINTF``, which uses printf to log instead of ``LogSink``,
and ``PW_LOG_FLAG_IGNORE``, which skips logging the log.
Loading

0 comments on commit 3dc3f1a

Please sign in to comment.