mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-22 19:48:00 +00:00
Add zdebuglog for basic debug logging and profiling
This commit is contained in:
parent
282b478fd2
commit
658ec4e4a7
17
init.zsh
17
init.zsh
@ -17,6 +17,19 @@ if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then
|
|||||||
fi
|
fi
|
||||||
unset min_zsh_version
|
unset min_zsh_version
|
||||||
|
|
||||||
|
typeset -F SECONDS
|
||||||
|
|
||||||
|
function zdebuglog {
|
||||||
|
if ! zstyle -t ":prezto" debug; then
|
||||||
|
echo no debug
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local format="$1"
|
||||||
|
shift
|
||||||
|
printf "[%f] $format\n" $SECONDS "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# zprezto convenience updater
|
# zprezto convenience updater
|
||||||
# The function is surrounded by ( ) instead of { } so it starts in a subshell
|
# The function is surrounded by ( ) instead of { } so it starts in a subshell
|
||||||
# and won't affect the environment of the calling shell
|
# and won't affect the environment of the calling shell
|
||||||
@ -93,7 +106,9 @@ function pmodload {
|
|||||||
|
|
||||||
# Load Prezto modules.
|
# Load Prezto modules.
|
||||||
for pmodule in "$pmodules[@]"; do
|
for pmodule in "$pmodules[@]"; do
|
||||||
|
zdebuglog "Started loading %q" $pmodule
|
||||||
if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then
|
if zstyle -t ":prezto:module:$pmodule" loaded 'yes' 'no'; then
|
||||||
|
zdebuglog "Module %q already loaded" $pmodule
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
locations=(${pmodule_dirs:+${^pmodule_dirs}/$pmodule(-/FN)})
|
locations=(${pmodule_dirs:+${^pmodule_dirs}/$pmodule(-/FN)})
|
||||||
@ -131,6 +146,7 @@ function pmodload {
|
|||||||
|
|
||||||
if (( $? == 0 )); then
|
if (( $? == 0 )); then
|
||||||
zstyle ":prezto:module:$pmodule" loaded 'yes'
|
zstyle ":prezto:module:$pmodule" loaded 'yes'
|
||||||
|
zdebuglog "Module %q loaded" $pmodule
|
||||||
else
|
else
|
||||||
# Remove the $fpath entry.
|
# Remove the $fpath entry.
|
||||||
fpath[(r)${pmodule_location}/functions]=()
|
fpath[(r)${pmodule_location}/functions]=()
|
||||||
@ -148,6 +164,7 @@ function pmodload {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
zdebuglog "Module %q failed to load" $pmodule
|
||||||
zstyle ":prezto:module:$pmodule" loaded 'no'
|
zstyle ":prezto:module:$pmodule" loaded 'no'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user