Having the timestamp and pid in the log path causes a large number of
log files to be generated, which makes it difficult to find the correct
one.
This commit removes the timestamp and pid from the log path, causing
all processes with the same name to log to the same file. To distinguish
individual processes, the log_write() function will also log the pid of
the calling process.
__init() {
local script_name
- local timestamp
script_name="${0##*/}"
return 1
fi
- if ! timestamp=$(date +"%Y-%m-%d.%H:%M"); then
- echo "Could not make timestamp for the log name" 1>&2
- return 1
- fi
-
declare -xgri __log_debug=3
declare -xgri __log_info=2
declare -xgri __log_warning=1
declare -xgi __log_verbosity="$__log_warning"
declare -xgr __log_path="$TOOLBOX_HOME/log"
- declare -xgr __log_file="$__log_path/$timestamp.$script_name.$$.log"
+ declare -xgr __log_file="$__log_path/$script_name.log"
if ! mkdir -p "$__log_path"; then
return 1
for line in "${@:3}"; do
local msg
- if ! msg=$(date +"%F %T %z $prefix $line"); then
+ if ! msg=$(date +"%F %T %z $$ $prefix $line"); then
echo "Could not get timestamp" 1>&2
return 1
fi