fix: formatting

This commit is contained in:
Roman 2024-12-06 22:29:26 +08:00
parent f7465746f0
commit 8065685e35
No known key found for this signature in database
GPG Key ID: B8FE070B54E11B75
2 changed files with 12 additions and 24 deletions

View File

@ -1,14 +1,14 @@
use clap::{Parser, ValueEnum};
use color_eyre::eyre::{eyre, Result};
use serde::{Deserialize, Serialize};
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
use std::path::PathBuf; use std::path::PathBuf;
use clap::{Parser, ValueEnum};
use serde::{Deserialize, Serialize};
use color_eyre::eyre::{eyre, Result};
use tracing::Level; use tracing::Level;
use nomos_tracing_service::{LoggerLayer, Tracing};
use overwatch_rs::services::ServiceData;
use nomos_tracing::logging::gelf::GelfConfig; use nomos_tracing::logging::gelf::GelfConfig;
use nomos_tracing::logging::local::FileConfig; use nomos_tracing::logging::local::FileConfig;
use nomos_tracing_service::{LoggerLayer, Tracing};
use overwatch_rs::services::ServiceData;
#[derive(ValueEnum, Clone, Debug, Default)] #[derive(ValueEnum, Clone, Debug, Default)]
pub enum LoggerLayerType { pub enum LoggerLayerType {
@ -19,7 +19,6 @@ pub enum LoggerLayerType {
Stderr, Stderr,
} }
#[derive(Parser, Debug, Clone)] #[derive(Parser, Debug, Clone)]
pub struct LogArgs { pub struct LogArgs {
/// Address for the Gelf backend /// Address for the Gelf backend
@ -48,10 +47,7 @@ pub struct Config {
} }
impl Config { impl Config {
pub fn update_from_args( pub fn update_from_args(mut self, log_args: LogArgs) -> Result<Self> {
mut self,
log_args: LogArgs,
) -> Result<Self> {
update_tracing(&mut self.tracing, log_args)?; update_tracing(&mut self.tracing, log_args)?;
Ok(self) Ok(self)
} }
@ -98,4 +94,4 @@ pub fn update_tracing(
}; };
} }
Ok(()) Ok(())
} }

View File

@ -1,8 +1,8 @@
mod config; mod config;
use clap::Parser;
use crate::config::{Config, LogArgs}; use crate::config::{Config, LogArgs};
use color_eyre::eyre::{Result}; use clap::Parser;
use color_eyre::eyre::Result;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
@ -14,21 +14,13 @@ struct Args {
log_args: LogArgs, log_args: LogArgs,
} }
fn main() -> Result<()> { fn main() -> Result<()> {
// Parse cluster options // Parse cluster options
let Args { let Args { config, log_args } = Args::parse();
config, let _config = serde_yaml::from_reader::<_, Config>(std::fs::File::open(config)?)?
log_args, .update_from_args(log_args)?;
} = Args::parse();
let config = serde_yaml::from_reader::<_, Config>(std::fs::File::open(config)?)?
.update_from_args(
log_args,
)?;
// Run the test suite // Run the test suite
Ok(()) Ok(())
} }