Skip to content

Commit c25c0ec

Browse files
committed
chore: improve logs
1 parent b28da87 commit c25c0ec

File tree

6 files changed

+23
-16
lines changed

6 files changed

+23
-16
lines changed

scripts/pit/lib/lib-demos.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ getTest() {
282282
## $1: name of the demo
283283
## $2: version to set
284284
setDemoVersion() {
285+
[ -z "$2" ] && return 1
285286
case "$1" in
286287
base-starter-flow-quarkus|mpr-demo)
287288
if setVersion vaadin.version "$2"; then
@@ -346,6 +347,7 @@ runDemo() {
346347

347348
if [ -z "$NOCURRENT" ]
348349
then
350+
bold -n ">>> PiT current $_demo"
349351
_current=`setDemoVersion $_demo current`
350352
[ -z "$_current" ] && reportError "Cannot get current version for $_demo"
351353
# 2
@@ -360,8 +362,9 @@ runDemo() {
360362
fi
361363
fi
362364
# 5
363-
if setDemoVersion $_demo $_version >/dev/null || [ -n "$NOCURRENT" ]
365+
if setDemoVersion $_demo $_version >/dev/null
364366
then
367+
bold -n ">>> PiT next $_demo"
365368
applyPatches "$_demo" next "$_version" prod || return 1
366369
if hasDev $_demo; then
367370
# 6

scripts/pit/lib/lib-k8s-cc.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ waitForCC() {
145145
log -n "Control Center up and running - Status: $H"
146146
return 0 ;;
147147
*)
148-
[ "$H" != "$last" ] && ([ -n "$VERBOSE" -a -n "$last" ] && echo "" || true) \
148+
[ "$H" != "$last" ] && ([ -n "$VERBOSE" -a -n "$last" ] && printnl || true) \
149149
&& log "Control center initializing - Status: $H" \
150150
|| ([ -n "$VERBOSE" ] && printf .)
151151
last="$H"
@@ -276,7 +276,7 @@ runPwTests() {
276276
# $2 tag to use for application images
277277
# $3 whether it is CC snapshot
278278
runControlCenter() {
279-
log -n "----> Running PiT for app: control-center version: '$1' tag: '$2' "
279+
bold -n "----> Running PiT for app: control-center version: '$1' tag: '$2' "
280280

281281
## Check if port 443 is busy
282282
[ -n "$TEST" ] || checkBusyPort "443" || return 1
@@ -313,7 +313,7 @@ runControlCenter() {
313313
## Uninstall the control-center if --keep-cc is not set
314314
[ -n "$KEEPCC" ] || uninstallCC --wait=false || return 1
315315

316-
log "----> Tested version '$1' of 'control-center'"
316+
bold "----> Tested version '$1' of 'control-center'"
317317

318318
return 0
319319
}

scripts/pit/lib/lib-k8s-vendor.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ patchDeployment() {
221221
uploadLocalImages() {
222222
case "$VENDOR" in
223223
kind)
224-
echo "" && log "** Loading images for vendor KinD **"
224+
log -n "** Loading images for vendor KinD **"
225225
for i in bakery bakery-cc cc-starter; do
226226
runCmd -q "Load docker image $i for Kind" \
227227
kind load docker-image $REGISTRY/$i:local --name "$CLUSTER" || return 1
@@ -233,7 +233,7 @@ uploadLocalImages() {
233233
done
234234
;;
235235
do)
236-
echo "" && log "** Loading images for vendor DO **"
236+
log -n "** Loading images for vendor DO **"
237237
for i in cbakery bakery-cc cc-starter; do
238238
runCmd -q "Tag image $i" docker tag $REGISTRY/$i:local $DO_REG_URL/$i:local || return 1
239239
runCmd -q "PUSH image $i" docker push $DO_REG_URL/$i:local || return 1

scripts/pit/lib/lib-utils.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,32 @@ printnl() {
9090
}
9191

9292
## log with some nice color
93-
log() {
93+
isnl() {
9494
expr "$1" : "\-" > /dev/null && _opt=${1#-} && shift || _opt=""
95-
[ "$_opt" = n ] && echo ""
95+
[ "$_opt" = n ] && echo "" >&2 || return 1
96+
true
97+
}
98+
log() {
99+
isnl $1 && shift
96100
[ -n "$TEST" ] && cmd "## $*" && return 0
97-
_p=`computeTime`
98101
print '> ' 0 32 "$*"
99102
printnl '' 2 36 " - "`computeTime`""
100103
}
101104
bold() {
102-
print '\n> ' 1 32 "$*"
103-
printnl '' 2 36 " - "`computeTime`"\n"
105+
isnl $1 && shift
106+
[ -n "$TEST" ] && cmd "## $*" && return 0
107+
print '> ' 1 32 "$*"
108+
printnl '' 2 36 " - "`computeTime`""
104109
}
105110
err() {
106111
printnl '> ' 0 31 "$*"
107112
}
108113
warn() {
114+
isnl $1 && shift
109115
printnl '> ' 0 33 "$*"
110116
}
111117
cmd() {
118+
isnl $1 && shift
112119
cmd_=`printf "$*" | tr -s " " | perl -pe 's|\n|\\\\\\\n|g'`
113120
printnl ' ' 1 34 " $cmd_"
114121
}

scripts/pit/lib/lib-validate.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ runValidations() {
3636
[ "$mode" = prod ] && expr "$compile" : "$MVN" >/dev/null && compile="$compile -Dmaven.compiler.showDeprecation"
3737
[ "$mode" = prod ] && expr "$cmd" : "$MVN" >/dev/null && cmd="$cmd -Dmaven.compiler.showDeprecation"
3838

39-
40-
echo "" >&2
41-
[ -z "$TEST" ] && bold "----> Running builds and tests on app $name, mode=$mode, port=$port, version=$version, mvn=$MVN"
42-
[ -n "$TEST" ] && cmd "### Run PiT for: app=$name mode=$mode version=$version"
39+
bold -n "--> Run PiT for: app=name, mode=$mode, port=$port, version=$version, mvn=$MVN"
4340
[ -n "$MAVEN_ARGS" ] && cmd "## MAVEN_ARGS='$MAVEN_ARGS'"
4441
[ -n "$MAVEN_OPTS" ] && cmd "## MAVEN_OPTS='$MAVEN_OPTS'"
4542

scripts/pit/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ DEFAULT_STARTERS=`echo "$PRESETS$DEMOS" | grep ...`
2626
run() {
2727
$1 "$2" "$3" "$PORT" "$VERSION" "$OFFLINE"
2828
_err=$?
29-
[ -n "$TEST" ] && cleanAll && echo "" && return 0
29+
[ -n "$TEST" ] && cleanAll && printnl && return 0
3030
if [ $_err = 0 ]; then
3131
log "==== '$2' was build and tested successfuly ===="
3232
success="$success $2"

0 commit comments

Comments
 (0)