1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-04-04 00:17:06 +00:00

Improve output formatting

This commit is contained in:
downtownallday 2022-06-29 12:30:38 -04:00
parent 8f1bb4f498
commit ecf5e3ddfb
3 changed files with 21 additions and 17 deletions

View File

@ -106,11 +106,15 @@ rest_urlencoded() {
fi
fi
if [ $REST_HTTP_CODE -lt 200 -o $REST_HTTP_CODE -ge 300 ]; then
REST_ERROR="REST status $REST_HTTP_CODE: $REST_OUTPUT"
if [ -z "$REST_OUTPUT" ]; then
REST_ERROR="Server returned status $REST_HTTP_CODE"
else
REST_ERROR="Server returned status $REST_HTTP_CODE: $REST_OUTPUT"
fi
echo "${F_DANGER}$REST_ERROR${F_RESET}" 1>&2
if $is_local && [ $REST_HTTP_CODE -ge 500 ]; then
echo -n "$F_WARN"
tail -100 /var/log/syslog
tail -100 /var/log/syslog | grep -i "(traceback|err|warn|fail|fatal|uncaught)" 1>&2
echo -n "$F_RESET"
fi
return 2

View File

@ -96,24 +96,24 @@ start_mail_capture() {
dump_capture_logs() {
# dump log files
record "[capture log dump]"
echo ""
echo "============= SYSLOG ================"
record ""
record "============= SYSLOG ================"
tail --lines=+$SYS_LOG_LINECOUNT /var/log/syslog 2>>$TEST_OF
echo ""
echo "============= SLAPD ================="
record ""
record "============= SLAPD ================="
tail --lines=+$SLAPD_LOG_LINECOUNT /var/log/ldap/slapd.log 2>>$TEST_OF
echo ""
echo "============= MAIL.ERR =============="
record ""
record "============= MAIL.ERR =============="
tail --lines=+$MAIL_ERRLOG_LINECOUNT /var/log/mail.err 2>>$TEST_OF
echo ""
echo "============= MAIL.LOG =============="
record ""
record "============= MAIL.LOG =============="
tail --lines=+$MAIL_LOG_LINECOUNT /var/log/mail.log 2>>$TEST_OF
echo ""
echo "============= DOVECOT ERRORS =============="
record ""
record "============= DOVECOT ERRORS =============="
doveadm log errors | tail --lines=+$DOVECOT_LOG_LINECOUNT 2>>$TEST_OF
echo ""
echo "============= Z-PUSH LOG =============="
tail --lines=+$ZPUSH_LOG_LINECOUND /var/log/z-push/z-push.log 2>>TEST_OF
record ""
record "============= Z-PUSH LOG =============="
tail --lines=+$ZPUSH_LOG_LINECOUND /var/log/z-push/z-push.log 2>>$TEST_OF
}
detect_syslog_error() {

View File

@ -16,7 +16,7 @@ test_zpush_logon() {
start_log_capture
rest_urlencoded POST "/Microsoft-Server-ActiveSync?Cmd=Ping&DeviceId=$devid&DeviceType=$devtype" "$alice" "$alice_pw" 2>>$TEST_OF
if [ $? -ne 0 ]; then
test_failure "$REST_ERROR"
test_failure "Error in REST call to z-push: $REST_ERROR"
fi
record "$REST_OUTPUT"
@ -49,7 +49,7 @@ test_zpush_logon() {
local count
let count="$ZPUSH_LOG_LINECOUNT + 1"
local matches
matches=( $(tail --lines=+$count /var/log/z-push/z-push.log 2>>$TEST_OF | grep -F -- "->Logon(" 2>>$TEST_OF | sed -E "s/^.* (.*)->Logon\\(.*$/\\1/" 2>>%TEST_OF | sort | uniq) )
matches=( $(tail --lines=+$count /var/log/z-push/z-push.log 2>>$TEST_OF | grep -F -- "->Logon(" 2>>$TEST_OF | sed -E "s/^.* (.*)->Logon\\(.*$/\\1/" 2>>$TEST_OF | sort | uniq) )
record "found successful logons for backends: ${matches[*]}"
if [ "${matches[*]}" != "$expected_backends" ]
then