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 
11 #include <iostream>
12 
13 extern "C" {
14 #include "tiffio.h"
15 }
16 
17 namespace boost { namespace gil {
18 
19 class tiff_no_log
20 {
21 public:
22 
tiff_no_log()23     tiff_no_log()
24     {
25         TIFFSetErrorHandler  ( nullptr );
26         TIFFSetWarningHandler( nullptr );
27     }
28 };
29 
30 class console_log
31 {
32 public:
33 
console_log()34     console_log()
35     {
36         TIFFSetErrorHandler  ( console_log::error   );
37         TIFFSetWarningHandler( console_log::warning );
38     }
39 
40 private:
41 
error(const char *,const char * fmt,va_list ap)42     static void error( const char* /* module */
43                      , const char* fmt
44                      , va_list ap
45                      )
46     {
47         char buf[1000];
48         sprintf(buf, fmt, ap);
49         std::cout << "error: " << buf << std::endl;
50     }
51 
warning(char const *,char const * fmt,va_list ap)52     static void warning( char const* /* module */
53                        , char const* fmt
54                        , va_list ap
55                        )
56     {
57         char buf[1000];
58         sprintf(buf, fmt, ap);
59         std::cout << "warning: " << fmt << std::endl;
60     }
61 };
62 
63 } // namespace gil
64 } // namespace boost
65 
66 #endif
67