Skip to content

Commit

Permalink
Remove old deserialize
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse authored and inikulin committed Aug 14, 2024
1 parent 8d6ff79 commit afd9094
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
2 changes: 1 addition & 1 deletion foundations/src/telemetry/log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use self::internal::current_log;
use crate::telemetry::log::init::build_log_with_drain;
use crate::telemetry::settings::LogVerbosity;
use crate::Result;
use slog::{Level, Logger, OwnedKV};
use slog::{Logger, OwnedKV};
use std::ops::Deref;
use std::sync::Arc;

Expand Down
27 changes: 0 additions & 27 deletions foundations/src/telemetry/settings/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,3 @@ pub struct LogVolumeMetricSettings {
/// Whether to enable log volume metrics
pub enabled: bool,
}

#[cfg(feature = "settings")]
mod with_settings_feature {
use super::*;

impl<'de> Deserialize<'de> for LogVerbosity {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
Level::from_str(&String::deserialize(deserializer)?)
.map_err(|_| de::Error::custom("incorrect verbosity level"))
.map(LogVerbosity)
}
}

impl Serialize for LogVerbosity {
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
s.serialize_str(self.0.as_str())
}
}

impl Settings for LogVerbosity {}
}
7 changes: 3 additions & 4 deletions foundations/tests/logging.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use foundations::telemetry::log::internal::LoggerWithKvNestingTracking;
use foundations::telemetry::log::{add_fields, set_verbosity, warn};
use foundations::telemetry::settings::{LoggingSettings, RateLimitingSettings};
use foundations::telemetry::settings::{LogVerbosity, LoggingSettings, RateLimitingSettings};
use foundations::telemetry::TestTelemetryContext;
use foundations_macros::with_test_telemetry;
use slog::Level;

#[with_test_telemetry(test)]
fn test_rate_limiter(mut ctx: TestTelemetryContext) {
Expand Down Expand Up @@ -39,7 +38,7 @@ fn test_exceed_limit_kv_nesting(_ctx: TestTelemetryContext) {
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
for _ in 0..((LoggerWithKvNestingTracking::MAX_NESTING / 2) + 1) {
add_fields! { "key1" => "hello" }
set_verbosity(Level::Info).expect("set_verbosity");
set_verbosity(LogVerbosity::Info).expect("set_verbosity");
}
})) {
Ok(_) => panic!("test case exceeded the maximum log KV nesting, but there was no panic"),
Expand Down Expand Up @@ -70,6 +69,6 @@ fn test_exceed_limit_kv_nesting(_ctx: TestTelemetryContext) {
fn test_not_exceed_limit_kv_nesting(_ctx: TestTelemetryContext) {
for _ in 0..((LoggerWithKvNestingTracking::MAX_NESTING / 2) - 5) {
add_fields! { "key1" => "hello" }
set_verbosity(Level::Info).expect("set_verbosity");
set_verbosity(LogVerbosity::Info).expect("set_verbosity");
}
}

0 comments on commit afd9094

Please sign in to comment.