I just have written a simple logger which append a message with time to a file. Now I also want to add error out to that log file for better understanding what went wrong. Here is my current code:
#!/bin/bash
logprint() {
echo "$(date +%T): $*" >> ./logfile
}
logdate() {
DATE=`date "+%d.%m.%Y"`
echo "-------------------- ${DATE} --------------------" >> ./logfile
}
The log print function takes arguments and simply write the date plus the message to the log file. The log date function simply writes the date at the beginning.
Now I would like to give the error output to the log print function. Whats the best way to do that?