mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
20 lines
426 B
Plaintext
20 lines
426 B
Plaintext
|
export def now [] {
|
||
|
date now | date format "%Y-%m-%dT%H:%M:%S%.3f"
|
||
|
}
|
||
|
|
||
|
export def format-message [
|
||
|
message: string,
|
||
|
format: string
|
||
|
prefix: string,
|
||
|
ansi
|
||
|
] {
|
||
|
[
|
||
|
["%MSG%" $message]
|
||
|
["%DATE%" (now)]
|
||
|
["%LEVEL%" $prefix]
|
||
|
["%ANSI_START%" $ansi]
|
||
|
["%ANSI_STOP%" (ansi reset)]
|
||
|
] | reduce --fold $format {
|
||
|
|it, acc| $acc | str replace --all $it.0 $it.1
|
||
|
}
|
||
|
}
|