Last active
September 7, 2020 16:09
-
-
Save FilBot3/e3eea8bb8f76b8ccadba56d8d6f32e84 to your computer and use it in GitHub Desktop.
A sample logging function for Bash scripts. Useful for CI/CD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| function exec_log { | |
| # This function prints a time + date stamps for use in Shell Scripts that are | |
| # used in CI/CD. This also allows the user to run the same commands locally | |
| # as they can in CI/CD. | |
| exec_date=$(date --rfc-3339=ns) | |
| echo "[${exec_date}]: $*" | |
| echo "[${exec_date}]: $(exec $*)" | |
| } | |
| exec_log echo 'Hello, World!' | |
| exec_log cat sample_logging.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment