diff --git a/README.md b/README.md index de74116..d4df2a9 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ mongo:link [--link-flags...] # link the mongo service to t mongo:linked # check if the mongo service is linked to an app mongo:links # list all apps linked to the mongo service mongo:list # list all mongo services -mongo:logs [-t|--tail] # print the most recent log(s) for this service +mongo:logs [-t|--tail] # print the most recent log(s) for this service mongo:promote # promote service as MONGO_URL in mongo:restart # graceful shutdown and restart of the mongo service container mongo:start # start a previously stopped mongo service @@ -154,12 +154,12 @@ dokku mongo:list ```shell # usage -dokku mongo:logs [-t|--tail] +dokku mongo: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: @@ -173,6 +173,12 @@ By default, logs will not be tailed, but you can do this with the --tail flag: dokku mongo:logs lollipop --tail ``` +The default tail setting is to show all logs, but an initial count can also be specified: + +```shell +dokku mongo:logs lollipop --tail 5 +``` + ### link the mongo 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 "$@"