#!/bin/bash

## Copyright (C) 2012 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

check_logs_do() {
   if [ -f "$check_log_file_name" ]; then
      local MSG="<p>Check Logs Result: <b>$check_log_file_name exists.</b> Please consider reporting any bugs inside this log.
(Be careful not to copy and paste personal information). You may delete this file now.</p>"
      $output_x ${output_opts[@]} --messagex --typex "warning" --message "$MSG"
      $output_cli ${output_opts[@]} --messagecli --typecli "warning" --message "$MSG"
      EXIT_CODE="1"
   else
      local MSG="<p>Check Logs Result: $check_log_file_name does not exist, ok.</p>"
      $output_x ${output_opts[@]} --messagex --typex "info" --message "$MSG"
      $output_cli ${output_opts[@]} --messagecli --typecli "info" --message "$MSG"
   fi
   return 0
}

check_logs() {
   if [ ! "$verbose" -ge "1" ]; then
      true "Skipping $FUNCNAME, because variable verbose is not set to 1."
      return 0
   fi

   check_log_file_name=~/".msgcollector/msgdispatcher-error.log"
   check_logs_do
   check_log_file_name="/run/systemcheck/.msgcollector/msgdispatcher-error.log"
   check_logs_do
   check_log_file_name="/var/lib/systemcheck/.msgcollector/msgdispatcher-error.log"
   check_logs_do
   check_log_file_name=~/".cache/tb/torbrowser_updater_error.log"
   check_logs_do

   return 0
}
