Skip to content

Commit 69e1ee0

Browse files
committed
Enhance log display options in verify.sh #680
1 parent 997edb1 commit 69e1ee0

File tree

3 files changed

+135
-35
lines changed

3 files changed

+135
-35
lines changed

RELEASE.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# RELEASE NOTES
22

3+
## v4.x.x - Unreleased
4+
5+
* Add enhanced log display options to `verify.sh`: supports `--logs` and `--no-logs` flags to control log output, and interactive prompt for log viewing. Log output is now cleaner and only shown when requested.
6+
*
7+
38
## v4.8.4 - pyPowerwall update
49

510
* Update pypowerwall to v0.14.0 - See updates: https://github.com/jasonacox/pypowerwall/releases/tag/v0.14.0 with Cloud updates to accommodate Tesla API changes (embedded TeslaPy patch) and fix a bug in FleetAPI for multi-site installations.
@@ -300,7 +305,7 @@ curl http://localhost:8675/control/reserve
300305

301306
## v4.1.2 - Cache 404 Responses
302307

303-
* Updated pyPowerwall to v0.7.11 to add cache and extended TTL for 404 responses from Powerwall as identified in issue jasonacox/Powerwall-Dashboard#449 by @jgleigh. This will help reduce load on Powerwall gateway that may be causing rate limiting for some users (Firmware 23.44.0+).
308+
* Updated pyPowerWall to v0.7.11 to add cache and extended TTL for 404 responses from Powerwall as identified in issue jasonacox/Powerwall-Dashboard#449 by @jgleigh. This will help reduce load on Powerwall gateway that may be causing rate limiting for some users (Firmware 23.44.0+).
304309
* Updated logic to disable vitals API calls for Firmware 23.44.0+
305310
* Added rate limit detection (429) and cooldown mode to allow Powerwall gateway time to recover.
306311

@@ -468,7 +473,7 @@ curl http://localhost:8675/control/reserve
468473
## v2.9.6 - Add Git Attributes
469474

470475
* Add `.gitattributes` file to help prevent issues such as .sh files being borked on Windows OS (ref #155) by @YesThatAllen in https://github.com/jasonacox/Powerwall-Dashboard/pull/270
471-
* Fix `verify.sh` to run on Windows OS in https://github.com/jasonacox/Powerwall-Dashboard/commit/25b77e53310d1668b2b3868e59fac55b82286f4f
476+
* Fix `verify.sh` to run on Windows OS in https://github.com/jasonacox/Powerwall-Dashboard/commit/25b77e53310d1668b2b3868e59fac55b82286f
472477

473478
## v2.9.5 - Repo Cleanup
474479

pypowerwall.env.sample

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,17 @@ PW_DEBUG=no # yes/no - Debug logging
1515
PW_STYLE=grafana-dark
1616
PW_NEG_SOLAR=yes # Set to no to zero out negative solar values
1717

18+
# Optional Network Settings
19+
#PW_CACHE_EXPIRE=20 # How long to cache data
20+
#PW_TIMEOUT=10 # How long to wait for PW or Cloud to respond
21+
#PW_POOL_MAXSIZE=15 # How many concurrent connections to PW
22+
23+
# Optional Network Reliability Settings
24+
#PW_SUPPRESS_NETWORK_ERRORS=no # Suppress network error logs
25+
#PW_NETWORK_ERROR_RATE_LIMIT=5 # Error log rate limit
26+
#PW_FAIL_FAST=no # Fast fail on bad connection
27+
#PW_GRACEFUL_DEGRADATION=yes # Use cached data if needed
28+
#PW_HEALTH_CHECK=yes # Enable health checks
29+
#PW_CACHE_TTL=30 # Max cache age (seconds)
30+
1831
# Additional Settings Here

verify.sh

Lines changed: 115 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,30 +101,54 @@ detect_light_background() {
101101
DEBUG_COLORS=false
102102
FORCE_BACKGROUND=""
103103
NO_COLOR=false
104+
SHOW_LOGS_OPTION="ask"
104105

105-
if [ $# -ne 0 ]; then
106-
if [[ "$1" == "-no-color" || "$1" == "--no-color" ]]; then
107-
NO_COLOR=true
108-
elif [[ "$1" == "-debug-colors" || "$1" == "--debug-colors" ]]; then
109-
DEBUG_COLORS=true
110-
elif [[ "$1" == "--light" || "$1" == "--lightbg" ]]; then
111-
FORCE_BACKGROUND="light"
112-
elif [[ "$1" == "--dark" || "$1" == "--darkbg" ]]; then
113-
FORCE_BACKGROUND="dark"
114-
elif [[ "$1" == "-h" || "$1" == "--help" ]]; then
115-
echo "Usage: $0 [OPTIONS]"
116-
echo ""
117-
echo "Options:"
118-
echo " --no-color Disable colored output"
119-
echo " --debug-colors Show color detection info"
120-
echo " --lightbg Force light background colors"
121-
echo " --darkbg Force dark background colors"
122-
echo " -h, --help Show this help message"
123-
echo ""
124-
echo "This script verifies the Powerwall Dashboard installation and services."
125-
exit 0
126-
fi
127-
fi
106+
while [[ $# -gt 0 ]]; do
107+
case "$1" in
108+
-no-color|--no-color)
109+
NO_COLOR=true
110+
shift
111+
;;
112+
-debug-colors|--debug-colors)
113+
DEBUG_COLORS=true
114+
shift
115+
;;
116+
--light|--lightbg)
117+
FORCE_BACKGROUND="light"
118+
shift
119+
;;
120+
--dark|--darkbg)
121+
FORCE_BACKGROUND="dark"
122+
shift
123+
;;
124+
--logs)
125+
SHOW_LOGS_OPTION="yes"
126+
shift
127+
;;
128+
--no-logs)
129+
SHOW_LOGS_OPTION="no"
130+
shift
131+
;;
132+
-h|--help)
133+
echo "Usage: $0 [OPTIONS]"
134+
echo ""
135+
echo "Options:"
136+
echo " --no-color Disable colored output"
137+
echo " --debug-colors Show color detection info"
138+
echo " --lightbg Force light background colors"
139+
echo " --darkbg Force dark background colors"
140+
echo " --logs Show logs automatically at end"
141+
echo " --no-logs Do not show logs automatically at end"
142+
echo " -h, --help Show this help message"
143+
echo ""
144+
echo "This script verifies the Powerwall Dashboard installation and services."
145+
exit 0
146+
;;
147+
*)
148+
shift
149+
;;
150+
esac
151+
done
128152

129153
# Detect background and set appropriate colors
130154
LIGHT_BG=false
@@ -246,7 +270,7 @@ if [ ! -f ${COMPOSE_ENV_FILE} ]; then
246270
fi
247271
echo -e ""
248272

249-
# pypowerwall
273+
# TEST: pypowerwall
250274
echo -e "${bold}Checking pypowerwall${dim}"
251275
echo -e "----------------------------------------------------------------------------"
252276
CONTAINER="pypowerwall"
@@ -267,6 +291,8 @@ echo -e -n "${dim} - Container ($CONTAINER): "
267291
RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2>/dev/null) || true
268292
if [ "$RUNNING" = "true" ]; then
269293
echo -e $GOOD
294+
# Capture last 10 lines of logs for later display
295+
PYPOWERWALL_LOG=$(docker logs $CONTAINER 2>&1 | tail -10)
270296
echo -e -n "${dim} - Service (port $PORT): "
271297
if running http://localhost:$PORT/stats 200 0 2>/dev/null; then
272298
echo -e $GOOD
@@ -329,7 +355,7 @@ if [ -f ${ENV_FILE} ] && ! grep -q "TZ=" ${ENV_FILE}; then
329355
fi
330356
echo -e ""
331357

332-
# telegraf
358+
# TEST: telegraf
333359
echo -e "${bold}Checking telegraf${dim}"
334360
echo -e "----------------------------------------------------------------------------"
335361
CONTAINER="telegraf"
@@ -355,6 +381,8 @@ echo -e -n "${dim} - Container ($CONTAINER): "
355381
RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2>/dev/null) || true
356382
if [ "$RUNNING" = "true" ]; then
357383
echo -e $GOOD
384+
# Capture last 10 lines of logs for later display
385+
TELEGRAF_LOG=$(docker logs $CONTAINER 2>&1 | tail -10)
358386
VER=`v=$(docker exec --tty $CONTAINER sh -c "telegraf --version") && echo "$v" || echo "$UKN"`
359387
elif [ "$RUNNING" = "false" ]; then
360388
echo -e "${alert}ERROR: Stopped${normal}"
@@ -366,7 +394,7 @@ fi
366394
echo -e "${dim} - Version: ${subbold}$VER"
367395
echo -e ""
368396

369-
# influxdb
397+
# TEST: influxdb
370398
echo -e "${bold}Checking influxdb${dim}"
371399
echo -e "----------------------------------------------------------------------------"
372400
CONTAINER="influxdb"
@@ -392,6 +420,8 @@ echo -e -n "${dim} - Container ($CONTAINER): "
392420
RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2>/dev/null) || true
393421
if [ "$RUNNING" = "true" ]; then
394422
echo -e $GOOD
423+
# Capture last 10 lines of logs for later display
424+
INFLUXDB_LOG=$(docker logs $CONTAINER 2>&1 | tail -10)
395425
echo -e -n "${dim} - Service (port $PORT): "
396426
if running http://localhost:$PORT/ping 204 1 2>/dev/null; then
397427
echo -e $GOOD
@@ -420,7 +450,7 @@ fi
420450
echo -e "${dim} - Version: ${subbold}$VER"
421451
echo -e ""
422452

423-
# grafana
453+
# TEST: grafana
424454
echo -e "${bold}Checking grafana${dim}"
425455
echo -e "----------------------------------------------------------------------------"
426456
CONTAINER="grafana"
@@ -441,6 +471,8 @@ echo -e -n "${dim} - Container ($CONTAINER): "
441471
RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2>/dev/null) || true
442472
if [ "$RUNNING" = "true" ]; then
443473
echo -e $GOOD
474+
# Capture last 10 lines of logs for later display
475+
GRAFANA_LOG=$(docker logs $CONTAINER 2>&1 | tail -10)
444476
VER=`v=$(docker exec --tty $CONTAINER sh -c "grafana-cli --version") && echo "$v" || echo "$UKN"`
445477
echo -e -n "${dim} - Service (port $PORT): "
446478
if running http://localhost:$PORT/login 200 1 2>/dev/null; then
@@ -498,6 +530,8 @@ if grep -q "tesla-history" powerwall.extend.yml 2>/dev/null; then
498530
RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2>/dev/null) || true
499531
if [ "$RUNNING" = "true" ]; then
500532
echo -e $GOOD
533+
# Capture last 10 lines of logs for later display
534+
TESLA_HISTORY_LOG=$(docker logs $CONTAINER 2>&1 | tail -10)
501535
VER=`v=$(docker exec -it $CONTAINER sh -c "python3 tesla-history.py --version") && echo "$v" || echo "$UKN"`
502536
elif [ "$RUNNING" = "false" ]; then
503537
echo -e "${alert}ERROR: Stopped${normal}"
@@ -510,7 +544,7 @@ if grep -q "tesla-history" powerwall.extend.yml 2>/dev/null; then
510544
echo -e ""
511545
fi
512546

513-
# weather411
547+
# TEST: weather411
514548
echo -e "${bold}Checking weather411${dim}"
515549
echo -e "----------------------------------------------------------------------------"
516550
CONTAINER="weather411"
@@ -525,6 +559,8 @@ else
525559
RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2>/dev/null) || true
526560
if [ "$RUNNING" = "true" ]; then
527561
echo -e $GOOD
562+
# Capture last 10 lines of logs for later display
563+
WEATHER411_LOG=$(docker logs $CONTAINER 2>&1 | tail -10)
528564
echo -e -n "${dim} - Service (port $PORT): "
529565
if running http://localhost:$PORT/stats 200 0 2>/dev/null; then
530566
echo -e $GOOD
@@ -572,6 +608,8 @@ if grep -q "ecowitt" powerwall.extend.yml 2>/dev/null; then
572608
RUNNING=$(docker inspect --format="{{.State.Running}}" $CONTAINER 2>/dev/null) || true
573609
if [ "$RUNNING" = "true" ]; then
574610
echo -e $GOOD
611+
# Capture last 10 lines of logs for later display
612+
ECOWITT_LOG=$(docker logs $CONTAINER 2>&1 | tail -10)
575613
echo -e -n "${dim} - Service (port $PORT): "
576614
if running http://localhost:$PORT/stats 200 0 2>/dev/null; then
577615
echo -e $GOOD
@@ -601,12 +639,56 @@ fi
601639

602640
if [ $ALLGOOD -ne 1 ]; then
603641
echo -e "${alert}One or more tests failed.${normal}"
604-
# Final cleanup of any remaining terminal input
605-
read -t 0.1 -n 1000 2>/dev/null || true
606-
exit 1
607642
else
608643
echo -e "${subbold}All tests succeeded.${normal}"
609-
# Final cleanup of any remaining terminal input
610-
read -t 0.1 -n 1000 2>/dev/null || true
644+
fi
645+
646+
# Final cleanup of any remaining terminal input
647+
read -t 0.1 -n 1000 2>/dev/null || true
648+
SHOW_LOGS=""
649+
650+
# Log display logic: use SHOW_LOGS_OPTION to override prompt
651+
if [[ "$SHOW_LOGS_OPTION" == "yes" ]]; then
652+
SHOW_LOGS="y"
653+
elif [[ "$SHOW_LOGS_OPTION" == "no" ]]; then
654+
SHOW_LOGS="n"
655+
else
656+
echo -en "\n${bold}Would you like to display the last 10 log lines for each running container? (y/N)${normal} "
657+
read -r SHOW_LOGS
658+
fi
659+
if [[ "$SHOW_LOGS" =~ ^[Yy]$ ]]; then
660+
if [ -n "$PYPOWERWALL_LOG" ]; then
661+
echo -e "\n${highlight}==== pypowerwall logs ====${normal}"
662+
echo "$PYPOWERWALL_LOG"
663+
fi
664+
if [ -n "$TELEGRAF_LOG" ]; then
665+
echo -e "\n${highlight}==== telegraf logs ====${normal}"
666+
echo "$TELEGRAF_LOG"
667+
fi
668+
if [ -n "$INFLUXDB_LOG" ]; then
669+
echo -e "\n${highlight}==== influxdb logs ====${normal}"
670+
echo "$INFLUXDB_LOG"
671+
fi
672+
if [ -n "$GRAFANA_LOG" ]; then
673+
echo -e "\n${highlight}==== grafana logs ====${normal}"
674+
echo "$GRAFANA_LOG"
675+
fi
676+
if [ -n "$TESLA_HISTORY_LOG" ]; then
677+
echo -e "\n${highlight}==== tesla-history logs ====${normal}"
678+
echo "$TESLA_HISTORY_LOG"
679+
fi
680+
if [ -n "$WEATHER411_LOG" ]; then
681+
echo -e "\n${highlight}==== weather411 logs ====${normal}"
682+
echo "$WEATHER411_LOG"
683+
fi
684+
if [ -n "$ECOWITT_LOG" ]; then
685+
echo -e "\n${highlight}==== ecowitt logs ====${normal}"
686+
echo "$ECOWITT_LOG"
687+
fi
688+
fi
689+
690+
if [ $ALLGOOD -ne 1 ]; then
691+
exit 1
692+
else
611693
exit 0
612694
fi

0 commit comments

Comments
 (0)