diff options
-rw-r--r-- | api/lib/akLogMessage/index.js | 4 | ||||
-rwxr-xr-x | config.sh | 1 | ||||
-rwxr-xr-x | install.sh | 2 | ||||
-rwxr-xr-x | lib/_ak_log | 31 | ||||
-rwxr-xr-x | lib/_ak_utils | 7 | ||||
-rwxr-xr-x | lib/_ak_zblock | 1 |
6 files changed, 33 insertions, 13 deletions
diff --git a/api/lib/akLogMessage/index.js b/api/lib/akLogMessage/index.js index e138f22..6dfb8f2 100644 --- a/api/lib/akLogMessage/index.js +++ b/api/lib/akLogMessage/index.js @@ -3,8 +3,8 @@ const config = require('../../config') module.exports = (type, message) => { const command = spawn( - "ak", - ["log", "-m", "ak-daemon", type, message] + "ak-log", + ["-m", "ak-daemon", type, message] ); var buffer = ""; @@ -20,7 +20,6 @@ export AK_ZCHAINASC="$AK_CONFIGDIR/zchain.asc" export AK_ZZCHAIN="$AK_CONFIGDIR/zzchain" export AK_ZLIST="$AK_WORKDIR/zlist" export AK_ZLATEST="$AK_WORKDIR/zlatest" -export AK_LOGSFILE="$AK_WORKDIR/logs" export AK_GPGHOME="$AK_WORKDIR/keyring" export AK_MINEDBLOCKSDIR="$AK_WORKDIR/mined_blocks" export AK_ZBLOCKSFILE="$AK_WORKDIR/zBlocksFile" @@ -61,8 +61,6 @@ else exit 3 fi -touch $AK_LOGSFILE - source ./lib/_ak_log source ./lib/_ak_script _ak_usage diff --git a/lib/_ak_log b/lib/_ak_log index 5ab6392..8a2d6d8 100755 --- a/lib/_ak_log +++ b/lib/_ak_log @@ -18,7 +18,24 @@ ### along with this program. If not, see <http://www.gnu.org/licenses/>. ### -source $AK_LIBDIR/_ak_utils +source $AK_LIBDIR/_ak_utils 2>/dev/null || source ./lib/_ak_utils 2>/dev/null + +if [ -n "${AK_WORKDIR}" ] +then + export AK_LOGSDIR="$AK_WORKDIR/logs" + if [ ! -d $AK_LOGSDIR ] + then + mkdir -p $AK_LOGSDIR + fi + export AK_LOGSFILE="$AK_LOGSDIR/log" + if [ ! -f $AK_LOGSFILE ] + then + touch $AK_LOGSFILE + fi +else + printf "Can't find AK_WORKDIR to work upon.\n" + exit 1 +fi function _ak_log_print_log_line(){ if [ -n "$1" ] @@ -28,7 +45,7 @@ function _ak_log_print_log_line(){ messagetype="$(echo "$*" | awk '{print $3}')" message="$(echo "$*" | cut -d ' ' -f4-)" printf '%s \033[1;32m%s\033[0;00m \033[1;31m%s\033[0;00m %s\n' \ - "$(date --date=@$timestamp +%Y%m%d_%H%M%S 2>/dev/null || date -r $timestamp +%Y%m%d_%H%M%S 2>/dev/null)" \ + "$(_ak_datetime_unix_to_human $timestamp)" \ "$program" \ "$messagetype" \ "$message" @@ -65,15 +82,15 @@ function _ak_log_grep(){ } function _ak_log_rotate(){ - cd $AK_WORKDIR + cd $AK_WORKDIR/$AK_LOGSDIR if [ -f $AK_LOGSFILE ] then - tar cvfz $AK_ARCHIVESDIR/logs_$(_ak_datetime_unix).tar.gz logs - cat /dev/null > $AK_WORKDIR/logs + gzip -c logs > $(_ak_datetime_unix)_logs.gz + cat /dev/null > logs fi - if [ -f $AK_WORKDIR/akd.log ] + if [ -f $AK_LOGSDIR/akd.log ] then - tar cvfz $AK_ARCHIVESDIR/akd-logs_$(_ak_datetime_unix).tar.gz akd.log + gzip -c akd.log > $(_ak_datetime_unix)_akd-logs.gz cat /dev/null > akd.log fi } diff --git a/lib/_ak_utils b/lib/_ak_utils index d1ca496..d437cb9 100755 --- a/lib/_ak_utils +++ b/lib/_ak_utils @@ -20,3 +20,10 @@ function _ak_datetime_unix(){ date -u +%s | tr -d '\n' } + +function _ak_datetime_unix_to_human(){ + if [ ! -z $1 ] && [ -n "$1" ] && [ "$(echo $1 | sed -e 's/[0-9]\{10\}//g')" == "" ] + then + date --date=@$1 +%Y%m%d_%H%M%S 2>/dev/null || date -r $1 +%Y%m%d_%H%M%S 2>/dev/null + fi +} diff --git a/lib/_ak_zblock b/lib/_ak_zblock index 4ae592a..b4a546b 100755 --- a/lib/_ak_zblock +++ b/lib/_ak_zblock @@ -126,7 +126,6 @@ function _ak_data_expand(){ # ak-zblock [IPFS CID] # # Returns a JSON array representing the chain retrieved. -# Logs messages to $LOGSFILE. function _ak_zblock_show(){ verify=1 if [ ! -z $1 ] && [ -n "$1" ] |