From ecbf09491dd40f656a15146abe55f69e5d9c9c48 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Thu, 2 Feb 2023 13:12:00 +0100 Subject: [PATCH] armbian-next: logging: introduce `RAW_LOG=yes` to export .tar with raw unprocessed logs (for development) --- lib/functions/logging/export-logs.sh | 11 +++++++++++ lib/functions/logging/trap-logging.sh | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/lib/functions/logging/export-logs.sh b/lib/functions/logging/export-logs.sh index a06dd8fab1..03508b70ac 100644 --- a/lib/functions/logging/export-logs.sh +++ b/lib/functions/logging/export-logs.sh @@ -174,3 +174,14 @@ function export_ansi_logs() { return 0 } + +function export_raw_logs() { + display_alert "Exporting RAW logs from" "${LOGDIR}" "info" + if [[ -z "${target_file}" ]]; then + display_alert "No target file specified for export_raw_logs()" "${target_file}" "err" + return 0 + fi + + # Just tar the logs directory into target_file + tar -C "${LOGDIR}" -cf "${target_file}" . +} diff --git a/lib/functions/logging/trap-logging.sh b/lib/functions/logging/trap-logging.sh index 801f5f27e3..ac6754296c 100644 --- a/lib/functions/logging/trap-logging.sh +++ b/lib/functions/logging/trap-logging.sh @@ -88,6 +88,13 @@ function trap_handler_cleanup_logging() { reset_uid_owner "${target_file}" local markdown_log_file="${target_file}" + # Export raw logs, in a tar. For development. + if [[ "${RAW_LOG:-no}" == "yes" ]]; then + local target_file="${target_path}/log-${ARMBIAN_LOG_CLI_ID}-${ARMBIAN_BUILD_UUID}.raw.tar" + export_raw_logs + reset_uid_owner "${target_file}" + fi + # If running in Github Actions, cat the markdown file to GITHUB_STEP_SUMMARY. It appends, docker and build logs will be together. if [[ "${CI}" == "true" ]] && [[ "${GITHUB_ACTIONS}" == "true" ]]; then display_alert "Exporting Markdown logs to GitHub Actions" "GITHUB_STEP_SUMMARY: '${GITHUB_STEP_SUMMARY}'" "info"