1 // 2 // Copyright (c) ZeroC, Inc. All rights reserved. 3 // 4 5 #ifndef ICEPY_LOGGER_H 6 #define ICEPY_LOGGER_H 7 8 #include <Config.h> 9 #include <Util.h> 10 #include <Ice/Logger.h> 11 12 namespace IcePy 13 { 14 15 // 16 // LoggerWrapper delegates to a Python implementation. 17 // 18 class LoggerWrapper : public Ice::Logger 19 { 20 public: 21 22 LoggerWrapper(PyObject*); 23 24 virtual void print(const std::string&); 25 virtual void trace(const std::string&, const std::string&); 26 virtual void warning(const std::string&); 27 virtual void error(const std::string&); 28 virtual std::string getPrefix(); 29 virtual Ice::LoggerPtr cloneWithPrefix(const std::string&); 30 PyObject* getObject(); 31 32 private: 33 34 PyObjectHandle _logger; 35 }; 36 typedef IceUtil::Handle<LoggerWrapper> LoggerWrapperPtr; 37 38 bool initLogger(PyObject*); 39 40 void cleanupLogger(); 41 42 // 43 // Create a Python object that delegates to a C++ implementation. 44 // 45 PyObject* createLogger(const Ice::LoggerPtr&); 46 47 } 48 49 extern "C" PyObject* IcePy_getProcessLogger(PyObject*, PyObject*); 50 extern "C" PyObject* IcePy_setProcessLogger(PyObject*, PyObject*); 51 52 #endif 53