log.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Copyright 2009 Christian Henning
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #ifndef BOOST_GIL_EXTENSION_IO_TIFF_DETAIL_LOG_HPP
  9. #define BOOST_GIL_EXTENSION_IO_TIFF_DETAIL_LOG_HPP
  10. #include <iostream>
  11. extern "C" {
  12. #include "tiffio.h"
  13. }
  14. namespace boost { namespace gil {
  15. class tiff_no_log
  16. {
  17. public:
  18. tiff_no_log()
  19. {
  20. TIFFSetErrorHandler ( nullptr );
  21. TIFFSetWarningHandler( nullptr );
  22. }
  23. };
  24. class console_log
  25. {
  26. public:
  27. console_log()
  28. {
  29. TIFFSetErrorHandler ( console_log::error );
  30. TIFFSetWarningHandler( console_log::warning );
  31. }
  32. private:
  33. static void error( const char* /* module */
  34. , const char* fmt
  35. , va_list ap
  36. )
  37. {
  38. char buf[1000];
  39. sprintf(buf, fmt, ap);
  40. std::cout << "error: " << buf << std::endl;
  41. }
  42. static void warning( char const* /* module */
  43. , char const* fmt
  44. , va_list ap
  45. )
  46. {
  47. char buf[1000];
  48. sprintf(buf, fmt, ap);
  49. std::cout << "warning: " << fmt << std::endl;
  50. }
  51. };
  52. } // namespace gil
  53. } // namespace boost
  54. #endif