Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #15274: Handle errors in log filter #2331

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion relay/sources/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ lint:

check: lint
cd relayd && cargo test
cd relayd && cargo audit
cd relayd && cargo audit --ignore RUSTSEC-2019-0011 #https://github.com/crossbeam-rs/crossbeam/issues/401
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To temporarily ignore the security alert and make the tests pass, I'll open an issue to remove it once fixed upstream.


# Clean

Expand Down
8 changes: 8 additions & 0 deletions relay/sources/relayd/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub enum Error {
InvalidTtl(String),
MissingTargetNodes,
InvalidHashType,
InvalidLogFilter(tracing_fmt::filter::env::ParseError),
}

impl Display for Error {
Expand Down Expand Up @@ -114,6 +115,7 @@ impl Display for Error {
f,
"Invalid hash type provided, available hash types : sha256, sha512"
),
InvalidLogFilter(ref err) => write!(f, "Log filter is invalid: {}", err),
}
}
}
Expand Down Expand Up @@ -226,3 +228,9 @@ impl From<log::SetLoggerError> for Error {
Error::SetLogLogger(err)
}
}

impl From<tracing_fmt::filter::env::ParseError> for Error {
fn from(err: tracing_fmt::filter::env::ParseError) -> Self {
Error::InvalidLogFilter(err)
}
}
2 changes: 1 addition & 1 deletion relay/sources/relayd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl JobConfig {
fn reload_logging(&self) -> Result<(), Error> {
LogConfig::new(&self.cli_cfg.configuration_dir).and_then(|log_cfg| {
self.handle
.reload(log_cfg.to_string())
.reload(EnvFilter::try_new(log_cfg.to_string())?)
.map_err(|e| e.into())
})
}
Expand Down