Skip to content

Instantly share code, notes, and snippets.

@Voronenko
Created November 4, 2022 14:32
Show Gist options
  • Save Voronenko/ce0d72edb3c337d95e59aa0d9130f5bd to your computer and use it in GitHub Desktop.
Save Voronenko/ce0d72edb3c337d95e59aa0d9130f5bd to your computer and use it in GitHub Desktop.
__timestamp(){
date "+%Y%m%dT%H%M%S"
}
__log(){
log_level="$1"
message="$2"
echo '{}' | \
jq --monochrome-output \
--compact-output \
--raw-output \
--arg timestamp "$(__timestamp)" \
--arg log_level "$log_level" \
--arg message "$message" \
'.timestamp=$timestamp|.log_level=$log_level|.message=$message'
}
__log "INFO" "Hello, World!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment