Skip to content

Commit

Permalink
Add config for log level in ballista (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted-Jiang authored Jul 28, 2022
1 parent 6bd0f6a commit 315f419
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
8 changes: 7 additions & 1 deletion ballista/rust/executor/executor_config_spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,10 @@ default = "604800"
name = "plugin_dir"
type = "String"
doc = "plugin dir"
default = "std::string::String::from(\"\")"
default = "std::string::String::from(\"\")"

[[param]]
name = "log_level_setting"
type = "String"
doc = "special log level for sub mod. link: https://docs.rs/env_logger/latest/env_logger/#enabling-logging. For example we want whole level is INFO but datafusion mode is DEBUG"
default = "std::string::String::from(\"INFO, datafusion=INFO\")"
8 changes: 6 additions & 2 deletions ballista/rust/executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;

#[tokio::main]
async fn main() -> Result<()> {
env_logger::init();

// parse command-line arguments
let (opt, _remaining_args) =
Config::including_optional_config_files(&["/etc/ballista/executor.toml"])
Expand All @@ -75,6 +73,12 @@ async fn main() -> Result<()> {
std::process::exit(0);
}

let special_mod_log_level = opt.log_level_setting;
env_logger::builder()
.parse_filters(&*special_mod_log_level)
.format_timestamp_millis()
.init();

let external_host = opt.external_host;
let bind_host = opt.bind_host;
let port = opt.bind_port;
Expand Down
8 changes: 7 additions & 1 deletion ballista/rust/scheduler/scheduler_config_spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,10 @@ default = "std::string::String::from(\"\")"
name = "sled_dir"
type = "String"
doc = "Sled dir: Opens a Db for saving schduler metadata at the specified path. This will create a new storage directory at the specified path if it does not already exist."
default = "std::string::String::from(\"\")"
default = "std::string::String::from(\"\")"

[[param]]
name = "log_level_setting"
type = "String"
doc = "special log level for sub mod. link: https://docs.rs/env_logger/latest/env_logger/#enabling-logging. For example we want whole level is INFO but datafusion mode is DEBUG"
default = "std::string::String::from(\"INFO, datafusion=INFO\")"
8 changes: 6 additions & 2 deletions ballista/rust/scheduler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ async fn start_server(

#[tokio::main]
async fn main() -> Result<()> {
env_logger::init();

// parse options
let (opt, _remaining_args) =
Config::including_optional_config_files(&["/etc/ballista/scheduler.toml"])
Expand All @@ -158,6 +156,12 @@ async fn main() -> Result<()> {
std::process::exit(0);
}

let special_mod_log_level = opt.log_level_setting;
env_logger::builder()
.parse_filters(&*special_mod_log_level)
.format_timestamp_millis()
.init();

let namespace = opt.namespace;
let bind_host = opt.bind_host;
let port = opt.bind_port;
Expand Down

0 comments on commit 315f419

Please sign in to comment.