Skip to content

Commit

Permalink
fix: better ./risedev l in server
Browse files Browse the repository at this point in the history
Signed-off-by: yihong0618 <[email protected]>
  • Loading branch information
yihong0618 committed Oct 10, 2024
1 parent b8c3fcb commit ba2d67d
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,45 @@ alias = "logs"

[tasks.logs]
category = "RiseDev - Start/Stop"
description = "Open logs with VSCode or dump in console"
description = "Open logs with Editor like VSCode and vim or dump in console"
script = '''
#!/usr/bin/env bash
code "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
if [[ -n "$EDITOR" ]]; then
if which "$EDITOR" &> /dev/null; then
$EDITOR "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
fi
fi
fi
# first try to use VSCode as the editor
if command -v code &> /dev/null; then
code "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
fi
fi
# Second try to use vim as the editor
if command -v vim &> /dev/null; then
vim "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
fi
fi
# Then try to use vi as the editor
if command -v vi &> /dev/null; then
vi "${PREFIX_LOG}" 2> /dev/null
if [[ $? -eq 0 ]]; then
exit 0
fi
fi
# If no editor is available or all attempts fail, dump log files
for out_file in ${PREFIX_LOG}/*.log
do
echo "~~~ Dump log file $out_file"
echo ""
cat "$out_file" | tail -n 300
echo "~~~ Dump log file $out_file"
echo ""
cat "$out_file" | tail -n 300
done
echo ""
Expand Down

0 comments on commit ba2d67d

Please sign in to comment.