aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Vander Stoep <jeffv@google.com>2023-02-02 22:38:29 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-02-02 22:38:29 +0000
commitff06600967ba81d2ac3afa831d6be67263bea531 (patch)
tree302ce0eff262fd39a93c2202fefd000cf8e110a1
parentd5b1d957916a6899c5c182cf46b45ecb73e5162e (diff)
parent5a5d65c3128d0768bf8e7c396f6792e1dd41df3d (diff)
downloadandroid_logger-ff06600967ba81d2ac3afa831d6be67263bea531.tar.gz
Revert "Update from 0.11.1 to 0.11.3" am: 5c4ac12779 am: cc8b6db1d0 am: 5a5d65c312
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/android_logger/+/2418359 Change-Id: I4b47f0bfd0e519b33ed557e827dd830f847cba2c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--CHANGELOG.md32
-rw-r--r--Cargo.toml4
-rw-r--r--Cargo.toml.orig4
-rw-r--r--METADATA13
-rw-r--r--patches/0001-Support-selecting-target-log-buffer.patch57
-rw-r--r--src/lib.rs41
6 files changed, 45 insertions, 106 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index 043ced7..0000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,32 +0,0 @@
-`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
diff --git a/Cargo.toml b/Cargo.toml
index 20ee6ba..1638036 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,7 @@
[package]
name = "android_logger"
-version = "0.11.3"
+version = "0.11.1"
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.10"
+version = "0.9"
default-features = false
[dependencies.log]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index f8da8dd..37c6496 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "android_logger"
-version = "0.11.3"
+version = "0.11.1"
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.10"
+version = "0.9"
default-features = false
[badges]
diff --git a/METADATA b/METADATA
index 57f4ae5..fba05dd 100644
--- a/METADATA
+++ b/METADATA
@@ -1,5 +1,5 @@
name: "android_logger"
-description: "()"
+description: "A logging implementation for `log` which hooks to android log output."
third_party {
url {
type: HOMEPAGE
@@ -7,14 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/android_logger/android_logger-0.11.3.crate"
+ value: "https://static.crates.io/crates/android_logger/android_logger-0.11.1.crate"
}
- version: "0.11.3"
- # Dual-licensed, using the least restrictive per go/thirdpartylicenses#same.
+ version: "0.11.1"
license_type: NOTICE
last_upgrade_date {
- year: 2023
- month: 1
- day: 19
+ year: 2022
+ month: 12
+ day: 5
}
}
diff --git a/patches/0001-Support-selecting-target-log-buffer.patch b/patches/0001-Support-selecting-target-log-buffer.patch
index ac253c4..6731ea8 100644
--- a/patches/0001-Support-selecting-target-log-buffer.patch
+++ b/patches/0001-Support-selecting-target-log-buffer.patch
@@ -1,7 +1,7 @@
-From 1eeada2dcbf268c7beaad0f48c6ca0664c646fde Mon Sep 17 00:00:00 2001
+From eaa9cff3c99ed9e172c9d9fb369b70f84587f297 Mon Sep 17 00:00:00 2001
From: Jeff Vander Stoep <jeffv@google.com>
-Date: Mon, 23 Jan 2023 07:55:16 +0100
-Subject: [PATCH] Support selecting target log buffer
+Date: Mon, 5 Dec 2022 12:38:24 +0100
+Subject: [PATCH 1/2] 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: I021158b302796cf7249177f60c8c984c988cb61c
+Change-Id: Id13515bb2cb042d1c31d4095444ae87cdcb13291
---
- src/lib.rs | 73 +++++++++++++++++++++++++++++++++++++++++++-----------
- 1 file changed, 59 insertions(+), 14 deletions(-)
+ src/lib.rs | 70 ++++++++++++++++++++++++++++++++++++++++++++----------
+ 1 file changed, 57 insertions(+), 13 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
-index d443c91..193bd29 100644
+index ef2027a..4bcce0c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -85,21 +85,49 @@ pub use env_logger::fmt::Formatter;
@@ -75,7 +75,7 @@ index d443c91..193bd29 100644
/// Underlying android logger backend
pub struct AndroidLogger {
-@@ -172,7 +200,7 @@ impl Log for AndroidLogger {
+@@ -160,7 +188,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 d443c91..193bd29 100644
// If a custom tag is used, add the module path to the message.
// Use PlatformLogWriter to output chunks if they exceed max size.
-@@ -215,6 +243,7 @@ impl AndroidLogger {
+@@ -203,6 +231,7 @@ impl AndroidLogger {
#[derive(Default)]
pub struct Config {
log_level: Option<Level>,
@@ -92,7 +92,7 @@ index d443c91..193bd29 100644
filter: Option<env_logger::filter::Filter>,
tag: Option<CString>,
custom_format: Option<FormatFn>,
-@@ -230,6 +259,15 @@ impl Config {
+@@ -218,6 +247,15 @@ impl Config {
self
}
@@ -108,7 +108,7 @@ index d443c91..193bd29 100644
fn filter_matches(&self, record: &Record) -> bool {
if let Some(ref filter) = self.filter {
filter.matches(record)
-@@ -271,6 +309,8 @@ pub struct PlatformLogWriter<'a> {
+@@ -259,6 +297,8 @@ pub struct PlatformLogWriter<'a> {
priority: LogPriority,
#[cfg(not(target_os = "android"))]
priority: Level,
@@ -117,31 +117,24 @@ index d443c91..193bd29 100644
len: usize,
last_newline_index: usize,
tag: &'a CStr,
-@@ -279,10 +319,11 @@ pub struct PlatformLogWriter<'a> {
+@@ -267,7 +307,7 @@ pub struct PlatformLogWriter<'a> {
impl<'a> PlatformLogWriter<'a> {
#[cfg(target_os = "android")]
-- 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 {
+- pub fn new(level: Level, tag: &CStr) -> PlatformLogWriter {
++ pub fn new(log_id: Option<LogId>, level: Level, tag: &CStr) -> PlatformLogWriter {
#[allow(deprecated)] // created an issue #35 for this
PlatformLogWriter {
- priority,
+ priority: match level {
+@@ -277,6 +317,7 @@ impl<'a> PlatformLogWriter<'a> {
+ Level::Error => LogPriority::ERROR,
+ Level::Trace => LogPriority::VERBOSE,
+ },
+ log_id: LogId::to_native(log_id),
len: 0,
last_newline_index: 0,
tag,
-@@ -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> {
+@@ -285,10 +326,11 @@ impl<'a> PlatformLogWriter<'a> {
}
#[cfg(not(target_os = "android"))]
@@ -154,7 +147,7 @@ index d443c91..193bd29 100644
len: 0,
last_newline_index: 0,
tag,
-@@ -365,7 +408,7 @@ impl<'a> PlatformLogWriter<'a> {
+@@ -345,7 +387,7 @@ impl<'a> PlatformLogWriter<'a> {
});
let msg: &CStr = unsafe { CStr::from_ptr(self.buffer.as_ptr().cast()) };
@@ -163,7 +156,7 @@ index d443c91..193bd29 100644
unsafe { *self.buffer.get_unchecked_mut(len) = last_byte };
}
-@@ -470,9 +513,11 @@ mod tests {
+@@ -450,9 +492,11 @@ mod tests {
// Filter is checked in config_filter_match below.
let config = Config::default()
.with_min_level(Level::Trace)
@@ -175,7 +168,7 @@ index d443c91..193bd29 100644
assert_eq!(config.tag, Some(CString::new("my_app").unwrap()));
}
-@@ -543,7 +588,7 @@ mod tests {
+@@ -523,7 +567,7 @@ mod tests {
fn platform_log_writer_init_values() {
let tag = CStr::from_bytes_with_nul(b"tag\0").unwrap();
@@ -184,7 +177,7 @@ index d443c91..193bd29 100644
assert_eq!(writer.tag, tag);
// Android uses LogPriority instead, which doesn't implement equality checks
-@@ -648,7 +693,7 @@ mod tests {
+@@ -628,7 +672,7 @@ mod tests {
}
fn get_tag_writer() -> PlatformLogWriter<'static> {
@@ -194,5 +187,5 @@ index d443c91..193bd29 100644
unsafe fn assume_init_slice<T>(slice: &[MaybeUninit<T>]) -> &[T] {
--
-2.39.0.246.g2a6d74b583-goog
+2.39.0.rc0.267.gcb52ba06e7-goog
diff --git a/src/lib.rs b/src/lib.rs
index ea2179e..59f942b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -135,10 +135,6 @@ impl AndroidLogger {
config: OnceCell::from(config),
}
}
-
- fn config(&self) -> &Config {
- self.config.get_or_init(Config::default)
- }
}
static ANDROID_LOGGER: OnceCell<AndroidLogger> = OnceCell::new();
@@ -156,21 +152,13 @@ impl Default for AndroidLogger {
}
impl Log for AndroidLogger {
- fn enabled(&self, metadata: &Metadata) -> bool {
- let config = self.config();
- // todo: consider __android_log_is_loggable.
- Some(metadata.level()) >= config.log_level
+ fn enabled(&self, _: &Metadata) -> bool {
+ true
}
fn log(&self, record: &Record) {
- let config = self.config();
-
- if !self.enabled(record.metadata()) {
- return;
- }
+ let config = self.config.get_or_init(Config::default);
- // this also checks the level, but only if a filter was
- // installed.
if !config.filter_matches(record) {
return;
}
@@ -313,31 +301,22 @@ pub struct PlatformLogWriter<'a> {
impl<'a> PlatformLogWriter<'a> {
#[cfg(target_os = "android")]
- pub fn new_with_priority(log_id: Option<LogId>, priority: log_ffi::LogPriority, tag: &CStr) -> PlatformLogWriter {
+ pub fn new(log_id: Option<LogId>, level: Level, tag: &CStr) -> PlatformLogWriter {
#[allow(deprecated)] // created an issue #35 for this
PlatformLogWriter {
- 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 {
+ priority: 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"))]