log.hpp 1.7 KB

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