Skip to content

Commit

Permalink
Enhance duration formatting in computeDuration function for better re…
Browse files Browse the repository at this point in the history
…adability
  • Loading branch information
fchastanet committed Dec 23, 2024
1 parent 96a78bc commit 17f4e6c
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 12 deletions.
13 changes: 12 additions & 1 deletion bin/awkLint
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -428,7 +429,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/buildPushDockerImage
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -416,7 +417,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/definitionLint
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -354,7 +355,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/doc
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -732,7 +733,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/dockerLint
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -535,7 +536,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/findShebangFiles
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -399,7 +400,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/frameworkLint
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -490,7 +491,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/installRequirements
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -653,7 +654,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/megalinter
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -439,7 +440,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/plantuml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -370,7 +371,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion bin/shellcheckLint
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -399,7 +400,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down
13 changes: 12 additions & 1 deletion src/Log/computeDuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Log::computeDuration() {
if ((${DISPLAY_DURATION:-0} == 1)); then
local -i duration=0
local -i delta=0
local durationStr deltaStr
local -i currentLogDate
currentLogDate="${EPOCHREALTIME/[^0-9]/}"
if ((LOG_LAST_LOG_DATE_INIT == 1)); then
Expand All @@ -26,7 +27,17 @@ Log::computeDuration() {
else
duration=$(((currentLogDate - FIRST_LOG_DATE) / 1000000))
delta=$(((currentLogDate - LOG_LAST_LOG_DATE) / 1000000))
LOG_LAST_DURATION_STR="${duration}s/+${delta}s"
if ((duration > 59)); then
durationStr=$(date -ud "@${duration}" +'%H:%M:%S')
else
durationStr="${duration}s"
fi
if ((delta > 59)); then
deltaStr=$(date -ud "@${delta}" +'%H:%M:%S')
else
deltaStr="${delta}s"
fi
LOG_LAST_DURATION_STR="${durationStr}/+${deltaStr}"
fi
LOG_LAST_LOG_DATE="${currentLogDate}"
# shellcheck disable=SC2034
Expand Down

0 comments on commit 17f4e6c

Please sign in to comment.