Skip to content

Commit

Permalink
remove unused tag from dart logging layer
Browse files Browse the repository at this point in the history
  • Loading branch information
boxdot committed Dec 18, 2024
1 parent 22db4d2 commit b020ef9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions applogic/src/api/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::StreamSink;
pub struct LogEntry {
pub time: DateTime<Utc>,
pub level: LogEntryLevel,
pub tag: String,
pub target: String,
pub msg: String,
}
Expand All @@ -34,6 +33,7 @@ impl From<tracing::Level> for LogEntryLevel {
}
}

pub fn create_log_stream(s: StreamSink<LogEntry>) {
crate::logging::dart::set_stream_sink(s)
pub fn create_log_stream(_s: StreamSink<LogEntry>) {
#[cfg(any(target_os = "android", target_os = "ios"))]
crate::logging::dart::set_stream_sink(_s)
}
9 changes: 3 additions & 6 deletions applogic/src/logging/dart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ static DART_SINK: LazyLock<RwLock<Option<StreamSink<LogEntry>>>> =
LazyLock::new(|| RwLock::new(None));

/// Tracing layer which forwards logs to the Dart side
pub(super) fn layer<S>(tag: &'static str) -> impl Layer<S>
pub(super) fn layer<S>() -> impl Layer<S>
where
S: Subscriber,
for<'span> S: LookupSpan<'span>,
{
SendToDartLayer { tag }
SendToDartLayer {}
}

pub(crate) fn set_stream_sink(stream_sink: StreamSink<LogEntry>) {
Expand All @@ -44,17 +44,14 @@ pub(crate) fn set_stream_sink(stream_sink: StreamSink<LogEntry>) {
}
}

struct SendToDartLayer {
tag: &'static str,
}
struct SendToDartLayer {}

impl SendToDartLayer {
fn log(&self, level: tracing::Level, target: String, logline: String) {
let time = Utc::now();
let entry = LogEntry {
time,
level: level.into(),
tag: self.tag.to_string(),
target,
msg: logline,
};
Expand Down
3 changes: 2 additions & 1 deletion applogic/src/logging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later

#[cfg(any(target_os = "android", target_os = "ios"))]
pub(crate) mod dart;

use std::sync::Once;
Expand Down Expand Up @@ -34,7 +35,7 @@ fn do_init_logger() -> Result<(), TryInitError> {
#[cfg(any(target_os = "android", target_os = "ios"))]
{
registry()
.with(dart::layer("phnx").with_filter(env_filter))
.with(dart::layer().with_filter(env_filter))
.try_init()?;
}

Expand Down

0 comments on commit b020ef9

Please sign in to comment.