mirror of
https://github.com/zplug/zplug
synced 2025-04-30 13:17:57 +02:00
Remove dead code from JSON logging format
Removes the dead if branch and a useless call of `tr`. After escaping, the string does not have newlines. Hence there is no need to remove them with `tr`.
This commit is contained in:
parent
2414b7ef5c
commit
c72855b338
@ -2,7 +2,6 @@ __zplug::log::format::with_json()
|
||||
{
|
||||
local -i i=1
|
||||
local level="${1:-"INFO"}" message="$2"
|
||||
local is_message_json=false
|
||||
|
||||
# Spit out to JSON
|
||||
builtin printf '{'
|
||||
@ -11,14 +10,9 @@ __zplug::log::format::with_json()
|
||||
builtin printf '"level":"%s",' "$level"
|
||||
builtin printf '"dir":"%s",' "$PWD"
|
||||
builtin printf '"message":'
|
||||
if $is_message_json; then
|
||||
builtin printf "$message"
|
||||
else
|
||||
builtin printf "$message" \
|
||||
| __zplug::utils::ansi::remove \
|
||||
| __zplug::utils::shell::json_escape \
|
||||
| tr -d '\n'
|
||||
fi
|
||||
builtin printf '%s' "$message" \
|
||||
| __zplug::utils::ansi::remove \
|
||||
| __zplug::utils::shell::json_escape
|
||||
builtin printf ','
|
||||
builtin printf '"trace":['
|
||||
for ((i = 1; i < $#functrace; i++))
|
||||
|
Loading…
Reference in New Issue
Block a user