diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2023-01-24 10:46:18 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-01-24 10:46:18 +0000 |
commit | 0796e4b20e1599910e5feb1553fa3b21f021c709 (patch) | |
tree | 3c4a238940950e24f56f2c5f1fbf1856d655c7a9 | |
parent | 35dcd503b723fac020eea1d2e58957c3f51cb402 (diff) | |
parent | cf9957cf636ab993d055b2a428287bdb07bd63b3 (diff) | |
download | android_logger-0796e4b20e1599910e5feb1553fa3b21f021c709.tar.gz |
Update from 0.11.1 to 0.11.3 am: 0af555c01f am: cf9957cf63
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/android_logger/+/2393379
Change-Id: I14e651ba8b7a3ba94ee7b6ac899301034203c25f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | CHANGELOG.md | 32 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Cargo.toml.orig | 4 | ||||
-rw-r--r-- | METADATA | 13 | ||||
-rw-r--r-- | TEST_MAPPING | 42 | ||||
-rw-r--r-- | patches/0001-Support-selecting-target-log-buffer.patch | 57 | ||||
-rw-r--r-- | src/lib.rs | 41 |
7 files changed, 148 insertions, 45 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..043ced7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,32 @@ +`android_logger` changelog +========================== + +All user visible changes to this project will be documented in this file. This project uses [Semantic Versioning 2.0.0]. + + + + +## [0.11.3] ยท 2022-12-20 +[0.11.3]: /../../tree/v0.11.3 + +[Diff](/../../compare/38186ece1056d90b8f75fd2a5eb5c860e0a1704e...v0.11.3) + +### Fixed + +- Broken compilation on [Android] targets. ([#59], [#58]) + +[#58]: /../../issues/58 +[#59]: /../../pull/59 + + + + +## Previous releases + +See [Git log](/../../commits/master?after=1a5a07ec6742f0069acc2be223c1bb3b6a9d15f8+0). + + + + +[Android]: https://www.android.com +[Semantic Versioning 2.0.0]: https://semver.org @@ -11,7 +11,7 @@ [package] name = "android_logger" -version = "0.11.1" +version = "0.11.3" authors = ["The android_logger Developers"] description = """ A logging implementation for `log` which hooks to android log output. @@ -31,7 +31,7 @@ repository = "https://github.com/Nercury/android_logger-rs" version = "0.2" [dependencies.env_logger] -version = "0.9" +version = "0.10" default-features = false [dependencies.log] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 37c6496..f8da8dd 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "android_logger" -version = "0.11.1" +version = "0.11.3" authors = ["The android_logger Developers"] license = "MIT OR Apache-2.0" readme = "README.md" @@ -25,7 +25,7 @@ version = "0.4" version = "0.2" [dependencies.env_logger] -version = "0.9" +version = "0.10" default-features = false [badges] @@ -1,5 +1,5 @@ name: "android_logger" -description: "A logging implementation for `log` which hooks to android log output." +description: "()" third_party { url { type: HOMEPAGE @@ -7,13 +7,14 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/android_logger/android_logger-0.11.1.crate" + value: "https://static.crates.io/crates/android_logger/android_logger-0.11.3.crate" } - version: "0.11.1" + version: "0.11.3" + # Dual-licensed, using the least restrictive per go/thirdpartylicenses#same. license_type: NOTICE last_upgrade_date { - year: 2022 - month: 12 - day: 5 + year: 2023 + month: 1 + day: 19 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index 526e77a..c608f2e 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -17,9 +17,18 @@ "name": "authfs_device_test_src_lib" }, { + "name": "compos_verify.test" + }, + { "name": "doh_unit_test" }, { + "name": "encryptedstore.test" + }, + { + "name": "fd_server.test" + }, + { "name": "keystore2_selinux_concurrency_test" }, { @@ -29,6 +38,15 @@ "name": "keystore2_test" }, { + "name": "libpvmfw_avb.integration_test" + }, + { + "name": "libuwb_adaptation_jni_tests" + }, + { + "name": "libuwb_uci_jni_rust_tests" + }, + { "name": "logger_device_unit_tests" }, { @@ -44,6 +62,9 @@ "name": "logger_test_multiple_init" }, { + "name": "open_then_run.test" + }, + { "name": "virtualizationservice_device_test" } ], @@ -64,9 +85,18 @@ "name": "authfs_device_test_src_lib" }, { + "name": "compos_verify.test" + }, + { "name": "doh_unit_test" }, { + "name": "encryptedstore.test" + }, + { + "name": "fd_server.test" + }, + { "name": "keystore2_selinux_concurrency_test" }, { @@ -76,6 +106,15 @@ "name": "keystore2_test" }, { + "name": "libpvmfw_avb.integration_test" + }, + { + "name": "libuwb_adaptation_jni_tests" + }, + { + "name": "libuwb_uci_jni_rust_tests" + }, + { "name": "logger_device_unit_tests" }, { @@ -91,6 +130,9 @@ "name": "logger_test_multiple_init" }, { + "name": "open_then_run.test" + }, + { "name": "virtualizationservice_device_test" } ] diff --git a/patches/0001-Support-selecting-target-log-buffer.patch b/patches/0001-Support-selecting-target-log-buffer.patch index 6731ea8..ac253c4 100644 --- a/patches/0001-Support-selecting-target-log-buffer.patch +++ b/patches/0001-Support-selecting-target-log-buffer.patch @@ -1,7 +1,7 @@ -From eaa9cff3c99ed9e172c9d9fb369b70f84587f297 Mon Sep 17 00:00:00 2001 +From 1eeada2dcbf268c7beaad0f48c6ca0664c646fde Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep <jeffv@google.com> -Date: Mon, 5 Dec 2022 12:38:24 +0100 -Subject: [PATCH 1/2] Support selecting target log buffer +Date: Mon, 23 Jan 2023 07:55:16 +0100 +Subject: [PATCH] Support selecting target log buffer Android has several different log buffers. Previously, this library would only support logging to the "Main" log. Now, it logs to the @@ -9,13 +9,13 @@ default log (which is Main for most processes), with the option to override which log buffer you send messages to in the config. Test: atest -Change-Id: Id13515bb2cb042d1c31d4095444ae87cdcb13291 +Change-Id: I021158b302796cf7249177f60c8c984c988cb61c --- - src/lib.rs | 70 ++++++++++++++++++++++++++++++++++++++++++++---------- - 1 file changed, 57 insertions(+), 13 deletions(-) + src/lib.rs | 73 +++++++++++++++++++++++++++++++++++++++++++----------- + 1 file changed, 59 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs -index ef2027a..4bcce0c 100644 +index d443c91..193bd29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,21 +85,49 @@ pub use env_logger::fmt::Formatter; @@ -75,7 +75,7 @@ index ef2027a..4bcce0c 100644 /// Underlying android logger backend pub struct AndroidLogger { -@@ -160,7 +188,7 @@ impl Log for AndroidLogger { +@@ -172,7 +200,7 @@ impl Log for AndroidLogger { // message must not exceed LOGGING_MSG_MAX_LEN // therefore split log message into multiple log calls @@ -84,7 +84,7 @@ index ef2027a..4bcce0c 100644 // If a custom tag is used, add the module path to the message. // Use PlatformLogWriter to output chunks if they exceed max size. -@@ -203,6 +231,7 @@ impl AndroidLogger { +@@ -215,6 +243,7 @@ impl AndroidLogger { #[derive(Default)] pub struct Config { log_level: Option<Level>, @@ -92,7 +92,7 @@ index ef2027a..4bcce0c 100644 filter: Option<env_logger::filter::Filter>, tag: Option<CString>, custom_format: Option<FormatFn>, -@@ -218,6 +247,15 @@ impl Config { +@@ -230,6 +259,15 @@ impl Config { self } @@ -108,7 +108,7 @@ index ef2027a..4bcce0c 100644 fn filter_matches(&self, record: &Record) -> bool { if let Some(ref filter) = self.filter { filter.matches(record) -@@ -259,6 +297,8 @@ pub struct PlatformLogWriter<'a> { +@@ -271,6 +309,8 @@ pub struct PlatformLogWriter<'a> { priority: LogPriority, #[cfg(not(target_os = "android"))] priority: Level, @@ -117,24 +117,31 @@ index ef2027a..4bcce0c 100644 len: usize, last_newline_index: usize, tag: &'a CStr, -@@ -267,7 +307,7 @@ pub struct PlatformLogWriter<'a> { +@@ -279,10 +319,11 @@ pub struct PlatformLogWriter<'a> { impl<'a> PlatformLogWriter<'a> { #[cfg(target_os = "android")] -- pub fn new(level: Level, tag: &CStr) -> PlatformLogWriter { -+ pub fn new(log_id: Option<LogId>, level: Level, tag: &CStr) -> PlatformLogWriter { +- pub fn new_with_priority(priority: log_ffi::LogPriority, tag: &CStr) -> PlatformLogWriter { ++ pub fn new_with_priority(log_id: Option<LogId>, priority: log_ffi::LogPriority, tag: &CStr) -> PlatformLogWriter { #[allow(deprecated)] // created an issue #35 for this PlatformLogWriter { - priority: match level { -@@ -277,6 +317,7 @@ impl<'a> PlatformLogWriter<'a> { - Level::Error => LogPriority::ERROR, - Level::Trace => LogPriority::VERBOSE, - }, + priority, + log_id: LogId::to_native(log_id), len: 0, last_newline_index: 0, tag, -@@ -285,10 +326,11 @@ impl<'a> PlatformLogWriter<'a> { +@@ -291,8 +332,9 @@ impl<'a> PlatformLogWriter<'a> { + } + + #[cfg(target_os = "android")] +- pub fn new(level: Level, tag: &CStr) -> PlatformLogWriter { ++ pub fn new(log_id: Option<LogId>, level: Level, tag: &CStr) -> PlatformLogWriter { + Self::new_with_priority( ++ log_id, + match level { + Level::Warn => LogPriority::WARN, + Level::Info => LogPriority::INFO, +@@ -305,10 +347,11 @@ impl<'a> PlatformLogWriter<'a> { } #[cfg(not(target_os = "android"))] @@ -147,7 +154,7 @@ index ef2027a..4bcce0c 100644 len: 0, last_newline_index: 0, tag, -@@ -345,7 +387,7 @@ impl<'a> PlatformLogWriter<'a> { +@@ -365,7 +408,7 @@ impl<'a> PlatformLogWriter<'a> { }); let msg: &CStr = unsafe { CStr::from_ptr(self.buffer.as_ptr().cast()) }; @@ -156,7 +163,7 @@ index ef2027a..4bcce0c 100644 unsafe { *self.buffer.get_unchecked_mut(len) = last_byte }; } -@@ -450,9 +492,11 @@ mod tests { +@@ -470,9 +513,11 @@ mod tests { // Filter is checked in config_filter_match below. let config = Config::default() .with_min_level(Level::Trace) @@ -168,7 +175,7 @@ index ef2027a..4bcce0c 100644 assert_eq!(config.tag, Some(CString::new("my_app").unwrap())); } -@@ -523,7 +567,7 @@ mod tests { +@@ -543,7 +588,7 @@ mod tests { fn platform_log_writer_init_values() { let tag = CStr::from_bytes_with_nul(b"tag\0").unwrap(); @@ -177,7 +184,7 @@ index ef2027a..4bcce0c 100644 assert_eq!(writer.tag, tag); // Android uses LogPriority instead, which doesn't implement equality checks -@@ -628,7 +672,7 @@ mod tests { +@@ -648,7 +693,7 @@ mod tests { } fn get_tag_writer() -> PlatformLogWriter<'static> { @@ -187,5 +194,5 @@ index ef2027a..4bcce0c 100644 unsafe fn assume_init_slice<T>(slice: &[MaybeUninit<T>]) -> &[T] { -- -2.39.0.rc0.267.gcb52ba06e7-goog +2.39.0.246.g2a6d74b583-goog @@ -135,6 +135,10 @@ impl AndroidLogger { config: OnceCell::from(config), } } + + fn config(&self) -> &Config { + self.config.get_or_init(Config::default) + } } static ANDROID_LOGGER: OnceCell<AndroidLogger> = OnceCell::new(); @@ -152,13 +156,21 @@ impl Default for AndroidLogger { } impl Log for AndroidLogger { - fn enabled(&self, _: &Metadata) -> bool { - true + fn enabled(&self, metadata: &Metadata) -> bool { + let config = self.config(); + // todo: consider __android_log_is_loggable. + Some(metadata.level()) >= config.log_level } fn log(&self, record: &Record) { - let config = self.config.get_or_init(Config::default); + let config = self.config(); + + if !self.enabled(record.metadata()) { + return; + } + // this also checks the level, but only if a filter was + // installed. if !config.filter_matches(record) { return; } @@ -301,22 +313,31 @@ pub struct PlatformLogWriter<'a> { impl<'a> PlatformLogWriter<'a> { #[cfg(target_os = "android")] - pub fn new(log_id: Option<LogId>, level: Level, tag: &CStr) -> PlatformLogWriter { + pub fn new_with_priority(log_id: Option<LogId>, priority: log_ffi::LogPriority, tag: &CStr) -> PlatformLogWriter { #[allow(deprecated)] // created an issue #35 for this PlatformLogWriter { - priority: match level { + priority, + log_id: LogId::to_native(log_id), + len: 0, + last_newline_index: 0, + tag, + buffer: uninit_array(), + } + } + + #[cfg(target_os = "android")] + pub fn new(log_id: Option<LogId>, level: Level, tag: &CStr) -> PlatformLogWriter { + Self::new_with_priority( + log_id, + match level { Level::Warn => LogPriority::WARN, Level::Info => LogPriority::INFO, Level::Debug => LogPriority::DEBUG, Level::Error => LogPriority::ERROR, Level::Trace => LogPriority::VERBOSE, }, - log_id: LogId::to_native(log_id), - len: 0, - last_newline_index: 0, tag, - buffer: uninit_array(), - } + ) } #[cfg(not(target_os = "android"))] |