Remove perf flag to streamline logging configuration (#6834)
This commit is contained in:
parent
c6436eb32f
commit
76ccd5668a
|
@ -15,7 +15,6 @@ pub fn evaluate_commands(
|
||||||
engine_state: &mut EngineState,
|
engine_state: &mut EngineState,
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
is_perf_true: bool,
|
|
||||||
table_mode: Option<Value>,
|
table_mode: Option<Value>,
|
||||||
) -> Result<Option<i64>> {
|
) -> Result<Option<i64>> {
|
||||||
// Translate environment variables from Strings to Values
|
// Translate environment variables from Strings to Values
|
||||||
|
@ -68,9 +67,7 @@ pub fn evaluate_commands(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if is_perf_true {
|
info!("evaluate {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("evaluate {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(exit_code)
|
Ok(exit_code)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ pub fn read_plugin_file(
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
plugin_file: Option<Spanned<String>>,
|
plugin_file: Option<Spanned<String>>,
|
||||||
storage_path: &str,
|
storage_path: &str,
|
||||||
is_perf_true: bool,
|
|
||||||
) {
|
) {
|
||||||
// Reading signatures from signature file
|
// Reading signatures from signature file
|
||||||
// The plugin.nu file stores the parsed signature collected from each registered plugin
|
// The plugin.nu file stores the parsed signature collected from each registered plugin
|
||||||
|
@ -44,9 +43,7 @@ pub fn read_plugin_file(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_perf_true {
|
info!("read_plugin_file {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("read_plugin_file {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
|
|
|
@ -19,7 +19,6 @@ pub fn evaluate_file(
|
||||||
engine_state: &mut EngineState,
|
engine_state: &mut EngineState,
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
is_perf_true: bool,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// Translate environment variables from Strings to Values
|
// Translate environment variables from Strings to Values
|
||||||
if let Some(e) = convert_env_values(engine_state, stack) {
|
if let Some(e) = convert_env_values(engine_state, stack) {
|
||||||
|
@ -54,9 +53,7 @@ pub fn evaluate_file(
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_perf_true {
|
info!("evaluate {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("evaluate {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ fn get_prompt_string(
|
||||||
config: &Config,
|
config: &Config,
|
||||||
engine_state: &EngineState,
|
engine_state: &EngineState,
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
is_perf_true: bool,
|
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
stack
|
stack
|
||||||
.get_env_var(engine_state, prompt)
|
.get_env_var(engine_state, prompt)
|
||||||
|
@ -44,14 +43,12 @@ fn get_prompt_string(
|
||||||
block,
|
block,
|
||||||
PipelineData::new(Span::new(0, 0)), // Don't try this at home, 0 span is ignored
|
PipelineData::new(Span::new(0, 0)), // Don't try this at home, 0 span is ignored
|
||||||
);
|
);
|
||||||
if is_perf_true {
|
info!(
|
||||||
info!(
|
"get_prompt_string (block) {}:{}:{}",
|
||||||
"get_prompt_string (block) {}:{}:{}",
|
file!(),
|
||||||
file!(),
|
line!(),
|
||||||
line!(),
|
column!()
|
||||||
column!()
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
match ret_val {
|
match ret_val {
|
||||||
Ok(ret_val) => Some(ret_val),
|
Ok(ret_val) => Some(ret_val),
|
||||||
|
@ -90,17 +87,10 @@ pub(crate) fn update_prompt<'prompt>(
|
||||||
engine_state: &EngineState,
|
engine_state: &EngineState,
|
||||||
stack: &Stack,
|
stack: &Stack,
|
||||||
nu_prompt: &'prompt mut NushellPrompt,
|
nu_prompt: &'prompt mut NushellPrompt,
|
||||||
is_perf_true: bool,
|
|
||||||
) -> &'prompt dyn Prompt {
|
) -> &'prompt dyn Prompt {
|
||||||
let mut stack = stack.clone();
|
let mut stack = stack.clone();
|
||||||
|
|
||||||
let left_prompt_string = get_prompt_string(
|
let left_prompt_string = get_prompt_string(PROMPT_COMMAND, config, engine_state, &mut stack);
|
||||||
PROMPT_COMMAND,
|
|
||||||
config,
|
|
||||||
engine_state,
|
|
||||||
&mut stack,
|
|
||||||
is_perf_true,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Now that we have the prompt string lets ansify it.
|
// Now that we have the prompt string lets ansify it.
|
||||||
// <133 A><prompt><133 B><command><133 C><command output>
|
// <133 A><prompt><133 B><command><133 C><command output>
|
||||||
|
@ -116,45 +106,20 @@ pub(crate) fn update_prompt<'prompt>(
|
||||||
left_prompt_string
|
left_prompt_string
|
||||||
};
|
};
|
||||||
|
|
||||||
let right_prompt_string = get_prompt_string(
|
let right_prompt_string =
|
||||||
PROMPT_COMMAND_RIGHT,
|
get_prompt_string(PROMPT_COMMAND_RIGHT, config, engine_state, &mut stack);
|
||||||
config,
|
|
||||||
engine_state,
|
|
||||||
&mut stack,
|
|
||||||
is_perf_true,
|
|
||||||
);
|
|
||||||
|
|
||||||
let prompt_indicator_string = get_prompt_string(
|
let prompt_indicator_string =
|
||||||
PROMPT_INDICATOR,
|
get_prompt_string(PROMPT_INDICATOR, config, engine_state, &mut stack);
|
||||||
config,
|
|
||||||
engine_state,
|
|
||||||
&mut stack,
|
|
||||||
is_perf_true,
|
|
||||||
);
|
|
||||||
|
|
||||||
let prompt_multiline_string = get_prompt_string(
|
let prompt_multiline_string =
|
||||||
PROMPT_MULTILINE_INDICATOR,
|
get_prompt_string(PROMPT_MULTILINE_INDICATOR, config, engine_state, &mut stack);
|
||||||
config,
|
|
||||||
engine_state,
|
|
||||||
&mut stack,
|
|
||||||
is_perf_true,
|
|
||||||
);
|
|
||||||
|
|
||||||
let prompt_vi_insert_string = get_prompt_string(
|
let prompt_vi_insert_string =
|
||||||
PROMPT_INDICATOR_VI_INSERT,
|
get_prompt_string(PROMPT_INDICATOR_VI_INSERT, config, engine_state, &mut stack);
|
||||||
config,
|
|
||||||
engine_state,
|
|
||||||
&mut stack,
|
|
||||||
is_perf_true,
|
|
||||||
);
|
|
||||||
|
|
||||||
let prompt_vi_normal_string = get_prompt_string(
|
let prompt_vi_normal_string =
|
||||||
PROMPT_INDICATOR_VI_NORMAL,
|
get_prompt_string(PROMPT_INDICATOR_VI_NORMAL, config, engine_state, &mut stack);
|
||||||
config,
|
|
||||||
engine_state,
|
|
||||||
&mut stack,
|
|
||||||
is_perf_true,
|
|
||||||
);
|
|
||||||
|
|
||||||
// apply the other indicators
|
// apply the other indicators
|
||||||
nu_prompt.update_all_prompt_strings(
|
nu_prompt.update_all_prompt_strings(
|
||||||
|
@ -166,9 +131,7 @@ pub(crate) fn update_prompt<'prompt>(
|
||||||
);
|
);
|
||||||
|
|
||||||
let ret_val = nu_prompt as &dyn Prompt;
|
let ret_val = nu_prompt as &dyn Prompt;
|
||||||
if is_perf_true {
|
info!("update_prompt {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("update_prompt {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_val
|
ret_val
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ pub fn evaluate_repl(
|
||||||
engine_state: &mut EngineState,
|
engine_state: &mut EngineState,
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
nushell_path: &str,
|
nushell_path: &str,
|
||||||
is_perf_true: bool,
|
|
||||||
prerun_command: Option<Spanned<String>>,
|
prerun_command: Option<Spanned<String>>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
use reedline::{FileBackedHistory, Reedline, Signal};
|
use reedline::{FileBackedHistory, Reedline, Signal};
|
||||||
|
@ -60,14 +59,12 @@ pub fn evaluate_repl(
|
||||||
|
|
||||||
let mut nu_prompt = NushellPrompt::new();
|
let mut nu_prompt = NushellPrompt::new();
|
||||||
|
|
||||||
if is_perf_true {
|
info!(
|
||||||
info!(
|
"translate environment vars {}:{}:{}",
|
||||||
"translate environment vars {}:{}:{}",
|
file!(),
|
||||||
file!(),
|
line!(),
|
||||||
line!(),
|
column!()
|
||||||
column!()
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Translate environment variables from Strings to Values
|
// Translate environment variables from Strings to Values
|
||||||
if let Some(e) = convert_env_values(engine_state, stack) {
|
if let Some(e) = convert_env_values(engine_state, stack) {
|
||||||
|
@ -92,18 +89,14 @@ pub fn evaluate_repl(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if is_perf_true {
|
info!(
|
||||||
info!(
|
"load config initially {}:{}:{}",
|
||||||
"load config initially {}:{}:{}",
|
file!(),
|
||||||
file!(),
|
line!(),
|
||||||
line!(),
|
column!()
|
||||||
column!()
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_perf_true {
|
info!("setup reedline {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("setup reedline {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut line_editor = Reedline::create();
|
let mut line_editor = Reedline::create();
|
||||||
|
|
||||||
|
@ -121,9 +114,7 @@ pub fn evaluate_repl(
|
||||||
engine_state.config.history_file_format,
|
engine_state.config.history_file_format,
|
||||||
);
|
);
|
||||||
if let Some(history_path) = history_path.as_deref() {
|
if let Some(history_path) = history_path.as_deref() {
|
||||||
if is_perf_true {
|
info!("setup history {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("setup history {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
let history: Box<dyn reedline::History> = match engine_state.config.history_file_format {
|
let history: Box<dyn reedline::History> = match engine_state.config.history_file_format {
|
||||||
HistoryFileFormat::PlainText => Box::new(
|
HistoryFileFormat::PlainText => Box::new(
|
||||||
|
@ -173,14 +164,12 @@ pub fn evaluate_repl(
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if is_perf_true {
|
info!(
|
||||||
info!(
|
"load config each loop {}:{}:{}",
|
||||||
"load config each loop {}:{}:{}",
|
file!(),
|
||||||
file!(),
|
line!(),
|
||||||
line!(),
|
column!()
|
||||||
column!()
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let cwd = get_guaranteed_cwd(engine_state, stack);
|
let cwd = get_guaranteed_cwd(engine_state, stack);
|
||||||
|
|
||||||
|
@ -201,15 +190,11 @@ pub fn evaluate_repl(
|
||||||
|
|
||||||
let config = engine_state.get_config();
|
let config = engine_state.get_config();
|
||||||
|
|
||||||
if is_perf_true {
|
info!("setup colors {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("setup colors {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
let color_hm = get_color_config(config);
|
let color_hm = get_color_config(config);
|
||||||
|
|
||||||
if is_perf_true {
|
info!("update reedline {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("update reedline {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
let engine_reference = std::sync::Arc::new(engine_state.clone());
|
let engine_reference = std::sync::Arc::new(engine_state.clone());
|
||||||
line_editor = line_editor
|
line_editor = line_editor
|
||||||
.with_highlighter(Box::new(NuHighlighter {
|
.with_highlighter(Box::new(NuHighlighter {
|
||||||
|
@ -266,18 +251,14 @@ pub fn evaluate_repl(
|
||||||
};
|
};
|
||||||
|
|
||||||
if config.sync_history_on_enter {
|
if config.sync_history_on_enter {
|
||||||
if is_perf_true {
|
info!("sync history {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("sync history {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Err(e) = line_editor.sync_history() {
|
if let Err(e) = line_editor.sync_history() {
|
||||||
warn!("Failed to sync history: {}", e);
|
warn!("Failed to sync history: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_perf_true {
|
info!("setup keybindings {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("setup keybindings {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Changing the line editor based on the found keybindings
|
// Changing the line editor based on the found keybindings
|
||||||
line_editor = match create_keybindings(config) {
|
line_editor = match create_keybindings(config) {
|
||||||
|
@ -301,9 +282,7 @@ pub fn evaluate_repl(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if is_perf_true {
|
info!("prompt_update {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("prompt_update {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Right before we start our prompt and take input from the user,
|
// Right before we start our prompt and take input from the user,
|
||||||
// fire the "pre_prompt" hook
|
// fire the "pre_prompt" hook
|
||||||
|
@ -323,19 +302,16 @@ pub fn evaluate_repl(
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = engine_state.get_config();
|
let config = engine_state.get_config();
|
||||||
let prompt =
|
let prompt = prompt_update::update_prompt(config, engine_state, stack, &mut nu_prompt);
|
||||||
prompt_update::update_prompt(config, engine_state, stack, &mut nu_prompt, is_perf_true);
|
|
||||||
|
|
||||||
entry_num += 1;
|
entry_num += 1;
|
||||||
|
|
||||||
if is_perf_true {
|
info!(
|
||||||
info!(
|
"finished setup, starting repl {}:{}:{}",
|
||||||
"finished setup, starting repl {}:{}:{}",
|
file!(),
|
||||||
file!(),
|
line!(),
|
||||||
line!(),
|
column!()
|
||||||
column!()
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let input = line_editor.read_line(prompt);
|
let input = line_editor.read_line(prompt);
|
||||||
let shell_integration = config.shell_integration;
|
let shell_integration = config.shell_integration;
|
||||||
|
|
|
@ -17,7 +17,6 @@ pub(crate) fn read_config_file(
|
||||||
engine_state: &mut EngineState,
|
engine_state: &mut EngineState,
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
config_file: Option<Spanned<String>>,
|
config_file: Option<Spanned<String>>,
|
||||||
is_perf_true: bool,
|
|
||||||
is_env_config: bool,
|
is_env_config: bool,
|
||||||
) {
|
) {
|
||||||
// Load config startup file
|
// Load config startup file
|
||||||
|
@ -105,16 +104,10 @@ pub(crate) fn read_config_file(
|
||||||
eval_config_contents(config_path, engine_state, stack);
|
eval_config_contents(config_path, engine_state, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_perf_true {
|
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn read_loginshell_file(
|
pub(crate) fn read_loginshell_file(engine_state: &mut EngineState, stack: &mut Stack) {
|
||||||
engine_state: &mut EngineState,
|
|
||||||
stack: &mut Stack,
|
|
||||||
is_perf_true: bool,
|
|
||||||
) {
|
|
||||||
// read and execute loginshell file if exists
|
// read and execute loginshell file if exists
|
||||||
if let Some(mut config_path) = nu_path::config_dir() {
|
if let Some(mut config_path) = nu_path::config_dir() {
|
||||||
config_path.push(NUSHELL_FOLDER);
|
config_path.push(NUSHELL_FOLDER);
|
||||||
|
@ -125,16 +118,10 @@ pub(crate) fn read_loginshell_file(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_perf_true {
|
info!("read_loginshell_file {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("read_loginshell_file {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn read_default_env_file(
|
pub(crate) fn read_default_env_file(engine_state: &mut EngineState, stack: &mut Stack) {
|
||||||
engine_state: &mut EngineState,
|
|
||||||
stack: &mut Stack,
|
|
||||||
is_perf_true: bool,
|
|
||||||
) {
|
|
||||||
let config_file = get_default_env();
|
let config_file = get_default_env();
|
||||||
eval_source(
|
eval_source(
|
||||||
engine_state,
|
engine_state,
|
||||||
|
@ -144,9 +131,7 @@ pub(crate) fn read_default_env_file(
|
||||||
PipelineData::new(Span::new(0, 0)),
|
PipelineData::new(Span::new(0, 0)),
|
||||||
);
|
);
|
||||||
|
|
||||||
if is_perf_true {
|
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
// Merge the environment in case env vars changed in the config
|
// Merge the environment in case env vars changed in the config
|
||||||
match nu_engine::env::current_dir(engine_state, stack) {
|
match nu_engine::env::current_dir(engine_state, stack) {
|
||||||
Ok(cwd) => {
|
Ok(cwd) => {
|
||||||
|
|
96
src/main.rs
96
src/main.rs
|
@ -7,7 +7,7 @@ mod tests;
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
use crate::config_files::NUSHELL_FOLDER;
|
use crate::config_files::NUSHELL_FOLDER;
|
||||||
use crate::logger::{configure, logger};
|
use crate::logger::{configure, logger};
|
||||||
use log::info;
|
use log::{info, Level};
|
||||||
use miette::Result;
|
use miette::Result;
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
use nu_cli::read_plugin_file;
|
use nu_cli::read_plugin_file;
|
||||||
|
@ -26,7 +26,6 @@ use nu_protocol::{
|
||||||
Spanned, SyntaxShape, Value,
|
Spanned, SyntaxShape, Value,
|
||||||
};
|
};
|
||||||
use nu_utils::stdout_write_all_and_flush;
|
use nu_utils::stdout_write_all_and_flush;
|
||||||
use std::{cell::RefCell, path::Path};
|
|
||||||
use std::{
|
use std::{
|
||||||
io::BufReader,
|
io::BufReader,
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -34,8 +33,7 @@ use std::{
|
||||||
Arc,
|
Arc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use std::{path::Path, str::FromStr};
|
||||||
thread_local! { static IS_PERF: RefCell<bool> = RefCell::new(false) }
|
|
||||||
|
|
||||||
// Inspired by fish's acquire_tty_or_exit
|
// Inspired by fish's acquire_tty_or_exit
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -268,18 +266,17 @@ fn main() -> Result<()> {
|
||||||
.expect("error setting number of threads");
|
.expect("error setting number of threads");
|
||||||
}
|
}
|
||||||
|
|
||||||
set_is_perf_value(binary_args.perf);
|
if binary_args.log_level.is_some() {
|
||||||
|
let mut level = binary_args
|
||||||
if binary_args.perf || binary_args.log_level.is_some() {
|
|
||||||
// since we're in this section, either perf is true or log_level has been set
|
|
||||||
// if log_level is set, just use it
|
|
||||||
// otherwise if perf is true, set the log_level to `info` which is what
|
|
||||||
// the perf calls are set to.
|
|
||||||
let level = binary_args
|
|
||||||
.log_level
|
.log_level
|
||||||
.map(|level| level.item)
|
.map(|level| level.item)
|
||||||
.unwrap_or_else(|| "info".to_string());
|
.unwrap_or_else(|| "info".to_string());
|
||||||
|
|
||||||
|
if Level::from_str(level.as_str()).is_err() {
|
||||||
|
eprintln!("ERROR: log library did not recognize log level '{level}', using default 'info'");
|
||||||
|
level = "info".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
let target = binary_args
|
let target = binary_args
|
||||||
.log_target
|
.log_target
|
||||||
.map(|target| target.item)
|
.map(|target| target.item)
|
||||||
|
@ -327,9 +324,7 @@ fn main() -> Result<()> {
|
||||||
PipelineData::new(Span::new(0, 0))
|
PipelineData::new(Span::new(0, 0))
|
||||||
};
|
};
|
||||||
|
|
||||||
if is_perf_true() {
|
info!("redirect_stdin {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("redirect_stdin {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
// First, set up env vars as strings only
|
// First, set up env vars as strings only
|
||||||
gather_parent_env_vars(&mut engine_state, &init_cwd);
|
gather_parent_env_vars(&mut engine_state, &init_cwd);
|
||||||
|
@ -343,7 +338,6 @@ fn main() -> Result<()> {
|
||||||
&mut stack,
|
&mut stack,
|
||||||
binary_args.plugin_file,
|
binary_args.plugin_file,
|
||||||
NUSHELL_FOLDER,
|
NUSHELL_FOLDER,
|
||||||
is_perf_true(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// only want to load config and env if relative argument is provided.
|
// only want to load config and env if relative argument is provided.
|
||||||
|
@ -352,15 +346,10 @@ fn main() -> Result<()> {
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
binary_args.env_file,
|
binary_args.env_file,
|
||||||
is_perf_true(),
|
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
config_files::read_default_env_file(
|
config_files::read_default_env_file(&mut engine_state, &mut stack)
|
||||||
&mut engine_state,
|
|
||||||
&mut stack,
|
|
||||||
is_perf_true(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if binary_args.config_file.is_some() {
|
if binary_args.config_file.is_some() {
|
||||||
|
@ -368,7 +357,6 @@ fn main() -> Result<()> {
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
binary_args.config_file,
|
binary_args.config_file,
|
||||||
is_perf_true(),
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -378,12 +366,9 @@ fn main() -> Result<()> {
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
input,
|
input,
|
||||||
is_perf_true(),
|
|
||||||
binary_args.table_mode,
|
binary_args.table_mode,
|
||||||
);
|
);
|
||||||
if is_perf_true() {
|
info!("-c command execution {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("-c command execution {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
match ret_val {
|
match ret_val {
|
||||||
Ok(Some(exit_code)) => std::process::exit(exit_code as i32),
|
Ok(Some(exit_code)) => std::process::exit(exit_code as i32),
|
||||||
Ok(None) => Ok(()),
|
Ok(None) => Ok(()),
|
||||||
|
@ -396,7 +381,6 @@ fn main() -> Result<()> {
|
||||||
&mut stack,
|
&mut stack,
|
||||||
binary_args.plugin_file,
|
binary_args.plugin_file,
|
||||||
NUSHELL_FOLDER,
|
NUSHELL_FOLDER,
|
||||||
is_perf_true(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// only want to load config and env if relative argument is provided.
|
// only want to load config and env if relative argument is provided.
|
||||||
|
@ -405,15 +389,10 @@ fn main() -> Result<()> {
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
binary_args.env_file,
|
binary_args.env_file,
|
||||||
is_perf_true(),
|
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
config_files::read_default_env_file(
|
config_files::read_default_env_file(&mut engine_state, &mut stack)
|
||||||
&mut engine_state,
|
|
||||||
&mut stack,
|
|
||||||
is_perf_true(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if binary_args.config_file.is_some() {
|
if binary_args.config_file.is_some() {
|
||||||
|
@ -421,7 +400,6 @@ fn main() -> Result<()> {
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
binary_args.config_file,
|
binary_args.config_file,
|
||||||
is_perf_true(),
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -432,7 +410,6 @@ fn main() -> Result<()> {
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
input,
|
input,
|
||||||
is_perf_true(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let last_exit_code = stack.get_env_var(&engine_state, "LAST_EXIT_CODE");
|
let last_exit_code = stack.get_env_var(&engine_state, "LAST_EXIT_CODE");
|
||||||
|
@ -444,9 +421,7 @@ fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if is_perf_true() {
|
info!("eval_file execution {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("eval_file execution {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_val
|
ret_val
|
||||||
} else {
|
} else {
|
||||||
|
@ -464,12 +439,9 @@ fn main() -> Result<()> {
|
||||||
&mut engine_state,
|
&mut engine_state,
|
||||||
&mut stack,
|
&mut stack,
|
||||||
config_files::NUSHELL_FOLDER,
|
config_files::NUSHELL_FOLDER,
|
||||||
is_perf_true(),
|
|
||||||
binary_args.execute,
|
binary_args.execute,
|
||||||
);
|
);
|
||||||
if is_perf_true() {
|
info!("repl eval {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("repl eval {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_val
|
ret_val
|
||||||
}
|
}
|
||||||
|
@ -487,23 +459,15 @@ fn setup_config(
|
||||||
is_login_shell: bool,
|
is_login_shell: bool,
|
||||||
) {
|
) {
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
read_plugin_file(
|
read_plugin_file(engine_state, stack, plugin_file, NUSHELL_FOLDER);
|
||||||
engine_state,
|
|
||||||
stack,
|
|
||||||
plugin_file,
|
|
||||||
NUSHELL_FOLDER,
|
|
||||||
is_perf_true(),
|
|
||||||
);
|
|
||||||
|
|
||||||
if is_perf_true() {
|
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
|
||||||
info!("read_config_file {}:{}:{}", file!(), line!(), column!());
|
|
||||||
}
|
|
||||||
|
|
||||||
config_files::read_config_file(engine_state, stack, env_file, is_perf_true(), true);
|
config_files::read_config_file(engine_state, stack, env_file, true);
|
||||||
config_files::read_config_file(engine_state, stack, config_file, is_perf_true(), false);
|
config_files::read_config_file(engine_state, stack, config_file, false);
|
||||||
|
|
||||||
if is_login_shell {
|
if is_login_shell {
|
||||||
config_files::read_loginshell_file(engine_state, stack, is_perf_true());
|
config_files::read_loginshell_file(engine_state, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give a warning if we see `$config` for a few releases
|
// Give a warning if we see `$config` for a few releases
|
||||||
|
@ -556,7 +520,6 @@ fn parse_commandline_args(
|
||||||
let interactive_shell = call.get_named_arg("interactive");
|
let interactive_shell = call.get_named_arg("interactive");
|
||||||
let commands: Option<Expression> = call.get_flag_expr("commands");
|
let commands: Option<Expression> = call.get_flag_expr("commands");
|
||||||
let testbin: Option<Expression> = call.get_flag_expr("testbin");
|
let testbin: Option<Expression> = call.get_flag_expr("testbin");
|
||||||
let perf = call.has_flag("perf");
|
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
let plugin_file: Option<Expression> = call.get_flag_expr("plugin-config");
|
let plugin_file: Option<Expression> = call.get_flag_expr("plugin-config");
|
||||||
let config_file: Option<Expression> = call.get_flag_expr("config");
|
let config_file: Option<Expression> = call.get_flag_expr("config");
|
||||||
|
@ -629,7 +592,6 @@ fn parse_commandline_args(
|
||||||
log_level,
|
log_level,
|
||||||
log_target,
|
log_target,
|
||||||
execute,
|
execute,
|
||||||
perf,
|
|
||||||
threads,
|
threads,
|
||||||
table_mode,
|
table_mode,
|
||||||
});
|
});
|
||||||
|
@ -656,7 +618,6 @@ struct NushellCliArgs {
|
||||||
log_level: Option<Spanned<String>>,
|
log_level: Option<Spanned<String>>,
|
||||||
log_target: Option<Spanned<String>>,
|
log_target: Option<Spanned<String>>,
|
||||||
execute: Option<Spanned<String>>,
|
execute: Option<Spanned<String>>,
|
||||||
perf: bool,
|
|
||||||
threads: Option<Value>,
|
threads: Option<Value>,
|
||||||
table_mode: Option<Value>,
|
table_mode: Option<Value>,
|
||||||
}
|
}
|
||||||
|
@ -676,11 +637,6 @@ impl Command for Nu {
|
||||||
.switch("login", "start as a login shell", Some('l'))
|
.switch("login", "start as a login shell", Some('l'))
|
||||||
.switch("interactive", "start as an interactive shell", Some('i'))
|
.switch("interactive", "start as an interactive shell", Some('i'))
|
||||||
.switch("version", "print the version", Some('v'))
|
.switch("version", "print the version", Some('v'))
|
||||||
.switch(
|
|
||||||
"perf",
|
|
||||||
"start and print performance metrics during startup",
|
|
||||||
Some('p'),
|
|
||||||
)
|
|
||||||
.named(
|
.named(
|
||||||
"testbin",
|
"testbin",
|
||||||
SyntaxShape::String,
|
SyntaxShape::String,
|
||||||
|
@ -708,7 +664,7 @@ impl Command for Nu {
|
||||||
.named(
|
.named(
|
||||||
"log-level",
|
"log-level",
|
||||||
SyntaxShape::String,
|
SyntaxShape::String,
|
||||||
"log level for performance logs",
|
"log level for diagnostic logs (error, warn, info, debug, trace). Off by default",
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
.named(
|
.named(
|
||||||
|
@ -797,16 +753,6 @@ impl Command for Nu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_perf_true() -> bool {
|
|
||||||
IS_PERF.with(|value| *value.borrow())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_is_perf_value(value: bool) {
|
|
||||||
IS_PERF.with(|new_value| {
|
|
||||||
*new_value.borrow_mut() = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_config_path(
|
fn set_config_path(
|
||||||
engine_state: &mut EngineState,
|
engine_state: &mut EngineState,
|
||||||
cwd: &Path,
|
cwd: &Path,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user