feat(logging): first very simple logging implementation

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-04-01 23:44:50 +02:00
parent 9e40d15e8a
commit 4ad318555e
2 changed files with 15 additions and 2 deletions

View File

@@ -48,9 +48,12 @@ function klipper_setup_dialog(){
status_msg "Initializing Klipper installation ..." status_msg "Initializing Klipper installation ..."
### return early if klipper already exists ### return early if klipper already exists
if [ -n "$(klipper_exists)" ]; then local klipper_services
klipper_services=$(klipper_exists)
if [ -n "${klipper_services}" ]; then
local error="At least one Klipper service is already installed:" local error="At least one Klipper service is already installed:"
for s in $(klipper_exists); do for s in ${klipper_services}; do
log "Found Klipper service: ${s}"
error="${error}\n ➔ ${s}" error="${error}\n ➔ ${s}"
done done
print_error "${error}" && return print_error "${error}" && return

View File

@@ -13,6 +13,7 @@ set -e
### base variables ### base variables
SYSTEMD="/etc/systemd/system" SYSTEMD="/etc/systemd/system"
LOGFILE="/tmp/kiauh.log"
# setting up some frequently used functions # setting up some frequently used functions
check_euid(){ check_euid(){
@@ -27,6 +28,15 @@ check_euid(){
fi fi
} }
function timestamp() {
date +"[%F %T]"
}
function log() {
local message="${1}"
echo -e "$(timestamp) ${message}" | tr -s " " >> "${LOGFILE}"
}
check_klipper_cfg_path(){ check_klipper_cfg_path(){
source_kiauh_ini source_kiauh_ini
if [ -z "${klipper_cfg_loc}" ]; then if [ -z "${klipper_cfg_loc}" ]; then