nushell/crates/nu-std/std
suimong e1ffaf2548
Improve std/log performance (#15614)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->
closes #15610 .

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

This PR attempts to improve the performance of `std/log *` by making the
following changes:
1. use explicit piping instead of `reduce` for constructing the log
message
2. constify `log-level`, `log-ansi`, `log-types` etc.
3. use `.` instead of `get` to access `$env` fields


# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

Nothing.

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->

---------

Co-authored-by: Ben Yang <ben@ya.ng>
Co-authored-by: suimong <suimong@users.noreply.github.com>
2025-04-22 13:00:20 -05:00
..
assert Replace "function" with "command" in several user-facing doc (#15129) 2025-02-17 14:10:38 -05:00
bench allow bench to handle larger numbers (#15162) 2025-02-25 15:02:42 +01:00
config Add env-conversions helpers to std (#15569) 2025-04-22 07:22:46 +08:00
dirs feat(std/dirs): retain state in subshells or with exec-restarts (#15080) 2025-02-11 19:51:43 -05:00
dt try to fix datetime-diff for ms, us, ns (#15537) 2025-04-10 06:52:11 -05:00
formats Replace "function" with "command" in several user-facing doc (#15129) 2025-02-17 14:10:38 -05:00
help refactor: tree-sitter-nu friendly alternative expressions (#15301) 2025-03-12 08:48:19 -05:00
input Fix usages of fmt to format number (#15041) 2025-02-07 23:50:33 +01:00
iter Replace "function" with "command" in several user-facing doc (#15129) 2025-02-17 14:10:38 -05:00
log Improve std/log performance (#15614) 2025-04-22 13:00:20 -05:00
math Virtual std module subdirectories (#14040) 2024-10-10 06:56:37 -05:00
prelude Add category to pwd and banner commands (#15330) 2025-03-17 20:22:01 +08:00
testing Custom command attributes (#14906) 2025-02-11 06:34:51 -06:00
util Fix path add bug when given a record (#15379) 2025-03-22 08:42:20 -04:00
xml Replace "function" with "command" in several user-facing doc (#15129) 2025-02-17 14:10:38 -05:00
mod.nu Replace "function" with "command" in several user-facing doc (#15129) 2025-02-17 14:10:38 -05:00