00001 // Copyright (C) 2009, Vaclav Haisman. All rights reserved. 00002 // 00003 // Redistribution and use in source and binary forms, with or without modifica- 00004 // tion, are permitted provided that the following conditions are met: 00005 // 00006 // 1. Redistributions of source code must retain the above copyright notice, 00007 // this list of conditions and the following disclaimer. 00008 // 00009 // 2. Redistributions in binary form must reproduce the above copyright notice, 00010 // this list of conditions and the following disclaimer in the documentation 00011 // and/or other materials provided with the distribution. 00012 // 00013 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00014 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00015 // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00016 // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00017 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 00018 // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00019 // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00020 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00021 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00022 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00023 00024 #ifndef LOG4CPLUS_WIN32CONSOLEAPPENDER_H 00025 #define LOG4CPLUS_WIN32CONSOLEAPPENDER_H 00026 00027 00028 #include "dcmtk/oflog/config.h" 00029 #if defined(_WIN32) && defined (LOG4CPLUS_HAVE_WIN32_CONSOLE) 00030 00031 #include "dcmtk/oflog/appender.h" 00032 #include "dcmtk/oflog/helpers/property.h" 00033 00034 00035 namespace log4cplus 00036 { 00037 00050 class LOG4CPLUS_EXPORT Win32ConsoleAppender 00051 : public Appender 00052 { 00053 public: 00054 explicit Win32ConsoleAppender (bool allocConsole = true); 00055 Win32ConsoleAppender (helpers::Properties const & properties, tstring& error); 00056 virtual ~Win32ConsoleAppender (); 00057 00058 virtual void close (); 00059 00060 protected: 00061 virtual void append (spi::InternalLoggingEvent const &); 00062 00063 void write_handle (HANDLE, tchar const *, size_t); 00064 void write_console (HANDLE, tchar const *, size_t); 00065 00066 bool alloc_console; 00067 00068 private: 00069 Win32ConsoleAppender (Win32ConsoleAppender const &); 00070 Win32ConsoleAppender & operator = (Win32ConsoleAppender const &); 00071 }; 00072 00073 } // namespace log4cplus 00074 00075 #endif 00076 00077 #endif // LOG4CPLUS_WIN32CONSOLEAPPENDER_H