00001 /*************************************************************************** 00002 * 00003 * Copyright (C) 2009-2010 Cassio Neri Moreira 00004 * 00005 * This file is part of the KeyValue library. 00006 * 00007 * The KeyValue library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License as published 00009 * by the Free Software Foundation, either version 3 of the License, or (at 00010 * your option) any later version. 00011 * 00012 * The KeyValue library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 00015 * Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License along 00018 * with KeyValue. If not, see <http://www.gnu.org/licenses/>. 00019 * 00020 **************************************************************************/ 00021 00028 #if _WIN32 || DOXYGEN 00029 00030 #ifndef KEYVALUE_SYS_LOGGER_WINDOWSCONSOLE_H_ 00031 #define KEYVALUE_SYS_LOGGER_WINDOWSCONSOLE_H_ 00032 00033 #undef UNICODE 00034 00035 #include <windows.h> 00036 00037 #include "keyvalue/extern/String.h" 00038 #include "keyvalue/sys/logger/LoggerImpl.h" 00039 #include "keyvalue/sys/logger/policy/AddPrefix.h" 00040 #include "keyvalue/sys/logger/policy/XtermColor.h" 00041 #include "keyvalue/sys/logger/policy/ForwardToGlobalLogger.h" 00042 00043 namespace keyvalue { 00044 namespace logger { 00045 00051 class WindowsConsole : public LoggerImpl<AddPrefix, XtermColor, 00052 ForwardToGlobalLogger> { 00053 00054 public: 00055 00056 typedef LoggerImpl<keyvalue::logger::AddPrefix, 00057 keyvalue::logger::XtermColor, 00058 keyvalue::logger::ForwardToGlobalLogger> MyBase_; 00059 00060 WindowsConsole(unsigned int level, const string& title, 00061 const string& path); 00062 00063 ~WindowsConsole(); 00064 00065 private: 00066 00067 HANDLE childStdInWrite_; 00068 PROCESS_INFORMATION childProcess_; 00069 00070 bool 00071 send(const string& message); 00072 00073 }; // class WindowsConsole 00074 00075 } // namespace logger 00076 } // namespace keyvalue 00077 00078 #endif // KEYVALUE_SYS_LOGGER_WINDOWSCONSOLE_H_ 00079 00080 #endif // _WIN32