mirror of
https://github.com/nushell/nushell
synced 2024-12-28 22:13:10 +00:00
20 lines
426 B
Text
20 lines
426 B
Text
|
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
|
||
|
}
|
||
|
}
|