diff --git a/prefix-output.sh b/prefix-output.sh index 0364bfd7..7cd3f820 100644 --- a/prefix-output.sh +++ b/prefix-output.sh @@ -1,7 +1,15 @@ #!/bin/sh # @see : https://github.com/Supervisor/supervisor/issues/553#issuecomment-1353523182 -exec 1> >( perl -ne '$| = 1; print "['"${SUPERVISOR_PROCESS_NAME}"'] | $_"' >&1) -exec 2> >( perl -ne '$| = 1; print "['"${SUPERVISOR_PROCESS_NAME}"'] | $_"' >&2) -exec "$@" \ No newline at end of file +# Check if structured logging is enabled +if [ "${SOURCEBOT_STRUCTURED_LOGGING_ENABLED}" = "true" ]; then + # Don't prefix output, just execute the command directly + exec "$@" +else + # Apply prefix to output + exec 1> >( perl -ne '$| = 1; print "['"${SUPERVISOR_PROCESS_NAME}"'] | $_"' >&1) + exec 2> >( perl -ne '$| = 1; print "['"${SUPERVISOR_PROCESS_NAME}"'] | $_"' >&2) + + exec "$@" +fi \ No newline at end of file