I'm trying to find an easy way to turn logging to a text file on and off much like the example seen here in Python. Their solution was to use a valid file name where logging is desired and to use the null device 'dev/null'
otherwise. They're using redirection but I wish to use fopen
.
Is there some way to do something like the following, which word work for Unix or Windows systems if that matters.
nullFID = fopen('/dev/nul', 'w')
The script I'm altering could benefit greatly with detailed logging in certain breaking scenarios where we want to pull up a fine level of detail for a handful of files but that would otherwise grow too large for the batch processing the script normally targets.
Looks like this can be done, someone posted an answer on MathWorks using a similar term of "null file". Not sure if that's valid terminology but could be a shortening of "null device file".
The way to reference the null device is OS dependent...
And it also appears the reference varies from Matlab releases. Consider the following script
And the following output generated from two versions of Matlab...
R2011b
R2015a