forked from zplug/zplug
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
77 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
#export PERIOD=10 | ||
export PERIOD=30 | ||
|
||
__zplug::job::polling::finalizer() | ||
__zplug::job::polling::periodic() | ||
{ | ||
# Display the corsor | ||
tput cnorm | ||
# TODO | ||
if [[ -f $_zplug_lock[job] ]]; then | ||
setopt nomonitor | ||
else | ||
if [[ -o monitor ]]; then | ||
return 0 | ||
fi | ||
if setopt monitor; then | ||
__zplug::log::write::info "turn monitor on" | ||
fi | ||
fi | ||
} | ||
|
||
#add-zsh-hook periodic __zplug::job::polling::finalizer | ||
add-zsh-hook periodic __zplug::job::polling::periodic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,32 @@ | ||
__zplug::log::format::with_json() | ||
{ | ||
local -i i=1 | ||
local level="${1:-"INFO"}" message | ||
local level="${1:-"INFO"}" message="$2" | ||
local is_message_json=false | ||
|
||
while (( $#argv > 0 )) | ||
do | ||
case "$argv[1]" in | ||
--message) | ||
message="$argv[2]"; shift | ||
;; | ||
--level) | ||
level="$argv[2]"; shift | ||
;; | ||
--message-json) | ||
is_message_json=true | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
# Spit out to JSON | ||
printf '{' | ||
printf '"pid":%d,' "$$" | ||
printf '"shlvl":%d,' "$SHLVL" | ||
printf '"level":"%s",' "$level" | ||
printf '"dir":"%s",' "$PWD" | ||
printf '"message":' | ||
builtin printf '{' | ||
builtin printf '"pid":%d,' "$$" | ||
builtin printf '"shlvl":%d,' "$SHLVL" | ||
builtin printf '"level":"%s",' "$level" | ||
builtin printf '"dir":"%s",' "$PWD" | ||
builtin printf '"message":' | ||
if $is_message_json; then | ||
printf "$message" | ||
builtin printf "$message" | ||
else | ||
printf "$message" \ | ||
builtin printf "$message" \ | ||
| __zplug::utils::ansi::remove \ | ||
| __zplug::utils::shell::json_escape \ | ||
| tr -d '\n' | ||
fi | ||
printf ',' | ||
printf '"trace":[' | ||
builtin printf ',' | ||
builtin printf '"trace":[' | ||
for ((i = 1; i < $#functrace; i++)) | ||
do | ||
printf '"%s",' "$functrace[$i]" | ||
builtin printf '"%s",' "$functrace[$i]" | ||
done | ||
printf '"%s"' "$functrace[$#functrace]" | ||
printf "]," | ||
printf '"date":"%s"' "$(strftime "%FT%T%z" $EPOCHSECONDS)" | ||
printf "}\n" | ||
builtin printf '"%s"' "$functrace[$#functrace]" | ||
builtin printf "]," | ||
builtin printf '"date":"%s"' "$(strftime "%FT%T%z" $EPOCHSECONDS)" | ||
builtin printf "}\n" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters