From 9fe8948ccdf61ee2db9adc2153f15f894fa08d80 Mon Sep 17 00:00:00 2001 From: lingr7 <37898999+lingr7@users.noreply.github.com> Date: Wed, 12 Oct 2022 20:47:14 +0800 Subject: [PATCH] add .sh filepath and the file linenumber in log filepath support after source, find the real log file adn lineno --- log.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/log.sh b/log.sh index ea15a23..a8ec98e 100755 --- a/log.sh +++ b/log.sh @@ -76,7 +76,7 @@ function log() { fi; if [ "${file}" -eq 1 ]; then - local file_line="${date} [${upper}] ${line}"; + local file_line="${date} [${upper}] "${BASH_SOURCE[1]}:"${BASH_LINENO}:\t${line}"; echo -e "${file_line}" >> "${file_path}" \ || _log_exception "echo -e \"${file_line}\" >> \"${file_path}\""; fi; @@ -103,7 +103,7 @@ function log() { local norm="${colours['DEFAULT']}"; local colour="${colours[${upper}]:-\033[31m}"; - local std_line="${colour}${date} [${upper}] ${line}${norm}"; + local std_line="${colour}${date} [${upper}] "${BASH_SOURCE[1]}:" ${BASH_LINENO}:\t${line}${norm}"; # Standard Output (Pretty) case "${level}" in