From cd43e57b999422980ea95df7f1d03117342e358e Mon Sep 17 00:00:00 2001 From: kaotisk Date: Fri, 1 Mar 2024 09:36:53 +0200 Subject: Simplifying logs --- bin/ak-comments | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'bin/ak-comments') diff --git a/bin/ak-comments b/bin/ak-comments index e20ab85..add1872 100755 --- a/bin/ak-comments +++ b/bin/ak-comments @@ -1,4 +1,8 @@ #!/bin/bash +PROGRAM="$(basename $0)" +logit(){ + ak-logthis "$PROGRAM" "$1" "$2" +} ZCOMMENTSDIR="$AK_WORKDIR/comments" TEMP="/tmp/aktmp" if [ ! -d $ZCOMMENTSDIR ]; then @@ -6,33 +10,33 @@ if [ ! -d $ZCOMMENTSDIR ]; then cd $ZCOMMENTSDIR ak-logthis "[INFO]" "zcommentsdir created" else - ak-logthis "[INFO]" "zcommentsdir found" + logit "INFO" "zcommentsdir found" fi _ak_modules_comments_create(){ - if [ ! -z $1 ] - then - REFER_TO="$1" - else - ak-logthis "[ERROR]" "No reference given" - echo "[ERROR]" "No reference given" - exit 1 - fi + if [ ! -z $1 ] + then + REFER_TO="$1" + else + logit "ERROR" "No reference given" + echo "ERROR" "No reference given" + exit 1 + fi TEMP="$(ak-tempassin)" cd $TEMP - export COMMENTS_FILE="$(date -u +%s)" - vi $COMMENTS_FILE - echo "Renaming..." - TO_FILE=$COMMENTS_FILE - IPFS_FILE=$(ak-ipfs-add $COMMENTS_FILE) - mv $COMMENTS_FILE $ZCOMMENTSDIR/$TO_FILE - _ak_modules_comments_add $TO_FILE - ak-logthis "[INFO]" "Adding to git repo..." - cd $ZCOMMENTSDIR - if [ ! -z $REFER_TO ] - then - ak-reference create $REFERENCE $REFER_TO - fi + export COMMENTS_FILE="$(date -u +%s)" + vi $COMMENTS_FILE + echo "Renaming..." + TO_FILE=$COMMENTS_FILE + IPFS_FILE=$(ak-ipfs-add $COMMENTS_FILE) + mv $COMMENTS_FILE $ZCOMMENTSDIR/$TO_FILE + _ak_modules_comments_add $TO_FILE + logit "INFO" "Adding to git repo..." + cd $ZCOMMENTSDIR + if [ ! -z $REFER_TO ] + then + ak-reference create $REFERENCE $REFER_TO + fi } _ak_modules_comments_index(){ -- cgit v1.2.3