diff --git a/README.md b/README.md index 088c521..e79066a 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ mysql:link [--link-flags...] # link the mysql service to t mysql:linked # check if the mysql service is linked to an app mysql:links # list all apps linked to the mysql service mysql:list # list all mysql services -mysql:logs [-t|--tail] # print the most recent log(s) for this service +mysql:logs [-t|--tail] # print the most recent log(s) for this service mysql:promote # promote service as DATABASE_URL in mysql:restart # graceful shutdown and restart of the mysql service container mysql:start # start a previously stopped mysql service @@ -153,12 +153,12 @@ dokku mysql:list ```shell # usage -dokku mysql:logs [-t|--tail] +dokku mysql:logs [-t|--tail] ``` flags: -- `-t|--tail`: do not stop when end of the logs are reached and wait for additional output +- `-t|--tail []`: do not stop when end of the logs are reached and wait for additional output You can tail logs for a particular service: @@ -172,6 +172,12 @@ By default, logs will not be tailed, but you can do this with the --tail flag: dokku mysql:logs lollipop --tail ``` +The default tail setting is to show all logs, but an initial count can also be specified: + +```shell +dokku mysql:logs lollipop --tail 5 +``` + ### link the mysql service to the app ```shell diff --git a/common-functions b/common-functions index ee756c8..d84a267 100755 --- a/common-functions +++ b/common-functions @@ -578,14 +578,14 @@ service_list() { service_logs() { declare desc="display logs for a service" - declare SERVICE="$1" TAIL_FLAG="$2" + declare SERVICE="$1" TAIL_FLAG="$2" TAIL_COUNT="$3" local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" local ID=$(cat "$SERVICE_ROOT/ID") local RE_INTEGER='^[0-9]+$' - DOKKU_LOGS_ARGS="--tail 100" + DOKKU_LOGS_ARGS="--tail $TAIL_COUNT" if [[ "$TAIL_FLAG" == "-t" ]] || [[ "$TAIL_FLAG" == "--tail" ]]; then - DOKKU_LOGS_ARGS="--follow" + DOKKU_LOGS_ARGS+=" --follow" fi docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist" diff --git a/help-functions b/help-functions index ddcfa69..3ff6dc9 100755 --- a/help-functions +++ b/help-functions @@ -202,6 +202,9 @@ fn-help-subcommand-args() { elif [[ "$arg" == *_LIST ]]; then arg=${arg%_*} args+=" <${arg//_/-}...>" + elif [[ "$arg" == *_OPTIONAL ]]; then + argName="${arg/_OPTIONAL/}" + args+=" [<${argName//_/-}>]" else args+=" <${arg//_/-}>" fi diff --git a/subcommands/logs b/subcommands/logs index 38c8209..55f13ac 100755 --- a/subcommands/logs +++ b/subcommands/logs @@ -10,16 +10,18 @@ service-logs-cmd() { #E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop #E by default, logs will not be tailed, but you can do this with the --tail flag: #E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop --tail + #E the default tail setting is to show all logs, but an initial count can also be specified + #E dokku $PLUGIN_COMMAND_PREFIX:logs lollipop --tail 5 #A service, service to run command against - #F -t|--tail, do not stop when end of the logs are reached and wait for additional output + #F -t|--tail [], do not stop when end of the logs are reached and wait for additional output declare desc="print the most recent log(s) for this service" local cmd="$PLUGIN_COMMAND_PREFIX:logs" argv=("$@") [[ ${argv[0]} == "$cmd" ]] && shift 1 - declare SERVICE="$1" TAIL_FLAG="$2" + declare SERVICE="$1" TAIL_FLAG="$2" TAIL_NUM_OPTIONAL="${3:-all}" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service" verify_service_name "$SERVICE" - service_logs "$SERVICE" "$TAIL_FLAG" + service_logs "$SERVICE" "$TAIL_FLAG" "$TAIL_NUM_OPTIONAL" } service-logs-cmd "$@"