I have a shell script which has a function to Log statements
#!/bin/sh
Log() {
echo $1 >> /some/logfile
}
Log "Test logging works"
This works great!
Next, I have a program which logs statements and if I want to have the logs from there added into a file, I can do like this
SomeProgram >> SomeFile.txt
This also works great!
But, what if I want to pass the logs from SomeProgram into my function Log while calling SomeProgram from the same shell script. Is that possible? Following are some tricks I tried which didn't work.
Log "SomeProgram >> SomeFile.txt"
Log(SomeProgram >> SomeFile.txt)
Question
So, how can I collect the logs from a program and keep passing them into the parameter of a function?
Environment:
Linux