Skip to content

Commit

Permalink
refactor: replace LogLevel type with String (#1167)
Browse files Browse the repository at this point in the history
Signed-off-by: Sander Pick <[email protected]>
  • Loading branch information
sanderpick authored Oct 9, 2024
1 parent c8bd8ea commit a1663dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 26 deletions.
1 change: 1 addition & 0 deletions contracts/sdk/IpcContractUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ abstract contract IpcExchangeUpgradeable is Initializable, IIpcHandler, OwnableU
_disableInitializers();
}

// solhint-disable-next-line func-name-mixedcase
function __IpcExchangeUpgradeable_init(address gatewayAddr_) public onlyInitializing {
gatewayAddr = gatewayAddr_;
__Ownable_init(msg.sender);
Expand Down
26 changes: 2 additions & 24 deletions ipc/observability/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,6 @@ use std::path::PathBuf;
use strum;
use tracing_appender;
use tracing_appender::rolling::Rotation;
use tracing_subscriber::filter::EnvFilter;

#[serde_as]
#[derive(Debug, Deserialize, Clone, Default, strum::EnumString, strum::Display)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "lowercase")]
pub enum LogLevel {
Off,
Error,
Warn,
#[default]
Info,
Debug,
Trace,
}

impl From<LogLevel> for EnvFilter {
fn from(val: LogLevel) -> Self {
// By default EnvFilter uses INFO, just like our default log level.
EnvFilter::try_new(val.to_string()).unwrap_or_default()
}
}

#[serde_as]
#[derive(Debug, Deserialize, Clone, strum::EnumString, strum::Display)]
Expand Down Expand Up @@ -73,14 +51,14 @@ pub struct TracingSettings {
#[serde_as]
#[derive(Debug, Deserialize, Clone, Default)]
pub struct ConsoleLayerSettings {
pub level: Option<LogLevel>,
pub level: Option<String>,
}

#[serde_as]
#[derive(Debug, Deserialize, Clone, Default)]
pub struct FileLayerSettings {
pub enabled: bool,
pub level: Option<LogLevel>,
pub level: Option<String>,
pub directory: Option<PathBuf>,
pub max_log_files: Option<usize>,
pub rotation: Option<RotationKind>,
Expand Down
4 changes: 2 additions & 2 deletions ipc/observability/src/traces.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2022-2024 Protocol Labs
// SPDX-License-Identifier: Apache-2.0, MIT

use crate::config::{FileLayerSettings, LogLevel, TracingSettings};
use crate::config::{FileLayerSettings, TracingSettings};
use crate::tracing_layers::DomainEventFilterLayer;
use std::num::NonZeroUsize;
use tracing::Level;
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn set_global_tracing_subscriber(config: &TracingSettings) -> Vec<WorkerGuar

let mut filter: EnvFilter = file_settings.level.clone().unwrap_or_default().into();
filter = filter.add_directive(
format!("{TRACING_TARGET}={}", LogLevel::Off)
format!("{TRACING_TARGET}=off")
.parse()
.expect("invalid logs level"),
);
Expand Down

0 comments on commit a1663dd

Please sign in to comment.