Skip to content

Commit 98ab36d

Browse files
committed
feat(init): update init function
1 parent e17cc7b commit 98ab36d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/bb-logger.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,14 @@ log::init()
8585
{
8686
local fileName="${1:-"debug"}"
8787

88-
[[ ! -d "$BB_LOG_DIR" ]] && { mkdir -p "$BB_LOG_DIR" || return 1; }
89-
[[ ! -f "$BB_LOG_DIR/$fileName" ]] && { touch "$BB_LOG_DIR/$fileName" || return 1; }
88+
if [[ "${fileName:0:1}" != "/" ]]; then
89+
[[ ! -d "$BB_LOG_DIR" ]] && { mkdir -p "$BB_LOG_DIR" || return 1; }
90+
[[ ! -f "$BB_LOG_DIR/$fileName" ]] && { touch "$BB_LOG_DIR/$fileName" || return 1; }
91+
else
92+
local fileDir="${fileName%/*}"
93+
[[ ! -d "$fileDir" ]] && { mkdir -p "$fileDir" || return 1; }
94+
[[ ! -f "$fileName" ]] && { touch "$fileName" || return 1; }
95+
fi
9096

9197
return 0
9298
}

0 commit comments

Comments
 (0)