Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions compose/bin/log
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ Options:
-h, --help Display help message"
}

generate_logs_file_path() {
local container_log_path="$1"
shift # This shifts the positional parameters to the left, so $2 becomes $1, $3 becomes $2, etc.
local log_files=("$@")
local log_file_paths=()

for file in "${log_files[@]}"; do
log_file_paths+=("$container_log_path$file")
done

echo "${log_file_paths[@]}"
}

get_all_logs_file_path() {
local logs_location="$1"

Expand All @@ -38,9 +25,17 @@ get_all_logs_file_path() {
if [[ $1 == "-h" || $1 == "--help" ]]; then
display_help
elif [[ -z $1 ]]; then
mapfile -t all_logs_file_path < <(get_all_logs_file_path "$CONTAINER_LOG_PATH")
all_logs_file_path=()
while IFS= read -r line; do
all_logs_file_path+=("$line")
done < <(get_all_logs_file_path "$CONTAINER_LOG_PATH")

bin/docker-compose exec phpfpm tail -f "${all_logs_file_path[@]}"
else
mapfile -t logs_file_path < <(generate_logs_file_path "$CONTAINER_LOG_PATH" "$@")
logs_file_path=()
for file in "$@"; do
logs_file_path+=("${CONTAINER_LOG_PATH}${file}")
done

bin/docker-compose exec phpfpm tail -f "${logs_file_path[@]}"
fi