Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add quiet flag #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions kubetail
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ where:
-n, --namespace The Kubernetes namespace where the pods are located. Defaults to \"${default_namespace}\".
-f, --follow Specify if the logs should be streamed. (true|false) Defaults to ${default_follow}.
-d, --dry-run Print the names of the matched pods and containers, then exit.
-q, --quiet Suppress kubetail info messages, only stream logs.
-P, --prefix Specify if add the pod name prefix before each line. (true|false) Defaults to ${default_prefix}.
-p, --previous Return logs for the previous instances of the pods, if available. (true|false) Defaults to ${default_previous}.
-s, --since Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to ${default_since}.
Expand Down Expand Up @@ -141,6 +142,13 @@ if [ "$#" -ne 0 ]; then
-d|--dry-run)
dryrun=true
;;
-q|--quiet)
if [ "$2" = "true" ]; then
quiet="true"
else
quiet="false"
fi
;;
-p|--previous)
if [ "$2" = "false" ]; then
previous="false"
Expand Down Expand Up @@ -283,7 +291,7 @@ fi

grep_matcher=''
if [ "${regex}" == 'regex' ]; then
echo "Using regex '${pod}' to match pods"
[[ "${quiet}" != 'true' ]] && echo "Using regex '${pod}' to match pods"
grep_matcher='-E'
fi

Expand Down Expand Up @@ -389,10 +397,13 @@ for pod in ${matching_pods[@]}; do
done

# Preview pod colors
echo "Will tail ${#display_names_preview[@]} logs..."
for preview in "${display_names_preview[@]}"; do
echo "$preview"
done
if [ "${quiet}" != 'true' ]; then
echo "Will tail ${#display_names_preview[@]} logs..."
for preview in "${display_names_preview[@]}"; do
echo "$preview"
done
fi


if [[ ${dryrun} == true ]];
then
Expand All @@ -410,4 +421,5 @@ if [[ ${follow} == false ]];
then
tail_follow_command=""
fi
tail ${tail_follow_command} -n +1 <( eval "${command_to_tail}" ) $line_buffered
# tail ${tail_follow_command} -n +1 <( eval "${command_to_tail}" ) $line_buffered
lnav <( eval "${command_to_tail}" )