I need to log all outputs / error logs from a shell script into a file with a standard format.
For example for file script.sh:
echo "I want to be a json message!"
echo "I also want to be a json message!"
executed like below:
./script.sh >> jsonmessages.log
should give me a file content like:
{timestamp: '2020-12-31 00:00:00', message: 'I want to be a json message!'}
{timestamp: '2020-12-31 00:00:00', message: 'I also want to be a json message!'}