i'm calling avfoundation method logging a lot of data stdout , there's no option turn logging off.
is possible write middleware process data before sending stdout?
something pseudocode:
process.beforeprint( data => {    if (data !== blacklisteddata) {       print(data);    } }); 
there number of options can employ using stdio functions. here's simple 1 redirects stdout log file:
class stdoutfilter {     let path: string = {         let paths = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true)         return (paths[0] nsstring).stringbyappendingpathcomponent("swift.log")     }()      func startfilter() {         freopen(path, "w", stdout)     }      func stopfilter() {         fclose(stdout)     } } you can use trivial implementation this:
let filter = stdoutfilter()  print("this goes stdout…")  filter.startfilter()  print("this gets logged file…") print("put avfoundation stuff here.")  filter.stopfilter()  print("and we're normal!") this modified in few obvious ways. redirect output /dev/null, example. try monitoring file , applying predicate determine whether filter should started or stopped, think that's more complex have time @ moment.
one final note: "w" in startfilter() function overwrite file if exists. use "a" if prefer append existing file.
Comments
Post a Comment