开发者

Can I redirect LibTIFF's error output without modifying LibTIFF source code?

开发者 https://www.devze.com 2023-03-19 06:59 出处:网络
By default, LibTIFF writes 开发者_如何学Call error outputs to stderr. This seems to be hardcoded. Is there a way to redirect it to either a string message handler or a file? Ideally without modifying

By default, LibTIFF writes 开发者_如何学Call error outputs to stderr. This seems to be hardcoded. Is there a way to redirect it to either a string message handler or a file? Ideally without modifying LibTIFF itself, but I'm okay with modifying if it is not too big of a change.

Clarification #1

I need to do this programmatically because I am using LibTIFF inside another library, and this library is not allowed to write anything to the stderr (otherwise it will mess up the application that uses my library). My library logs all errors to a file - I want LibTIFF errors to be redirected to this file as well.

I don't have control on the applications that use my library.

Clarification #2

My library is in C++ and runs on Windows.

If modification of LibTIFF is necessary, suggestions and advices are welcome.


You are probably should try using TIFFSetErrorHandler function in libtiff.

Using this function a user can change the way the library handles errors. No modification to the code of libtiff is required to redirect error output to something other that stderr.

http://www.unix.com/man-page/OpenSolaris/3tiff/TIFFSetErrorHandler/


Add the following to the end of the libtiff command:

 2>filename.txt

where filename.txt is the name of the file to save the output to. This syntax, however, may be platform-dependent; at the least, this syntax should work in Linux and Windows.


Yes, add 2> outputfile

Source: http://www.lamfa.u-picardie.fr/asch/f/MeCS/courseware/users/help/general/unix/redirection.html

0

精彩评论

暂无评论...
验证码 换一张
取 消