ICE的日志和统计接口

1、获取日志对象:
   virtual LoggerPtr getLogger() const;
2、日志对象提供的方法:
   local interface Logger
   {
        void print(string message);
        void trace(string category, string message);
        void warning(string message);
        void error(string message);
        Logger cloneWithPrefix(string prefix);
    };
3、communicator提供的默认日志接口是打屏的,可以通过如下方法定制日志接口:
   Ice::InitializationData id;
   id.logger = new MyLoggerI();
   Ice::Communicator ic = Ice::Initiliaze(argc, argv, id);
4、也可以通过插件设置日志
   class MyLoggerI : public Ice::Logger
   {
   public:
        void print(string message);
        void trace(string category, string message);
        void warning(string message);
        void error(string message);
        Logger cloneWithPrefix(string prefix);
   };
   extern "C"
   {
   ICE_DECLSPEC_EXPORT Ice::Plugin* createLogger(const Ice::Communicator& ic, const std::string& name, 
                                                 const Ice::StringSeq& args)
{
   Ice::LoggerPtr logger = new MyLoggerI();
return new Ice::LoggerPlugin(ic, logger);
}
   }
   编译成动态库libmylogger.so
   配置属性:Ice.Plugin.MyLogger = mylogger::createLogger
4、ICE提供了一系列的工具类来处理日志:Ice::Error、Ice::Warning、Ice::Trace、Ice::Print
    Ice::Error err(communicator->getLogger());
err<<"This is error "<<myErrorString;
5、ICE提供了统计接口用来统计网络流量,具体的接口使用如下:
   local interface stats
   {
        void bytesSent(std::string& protocol, Ice::Int num);
void bytesReceived(std::string& protocol, Ice::Int num);
    };  
   Ice::InitializationData id;
   id.stats = new MyStatsI();
   Ice::Communicator ic = Ice::Initiliaze(argc, argv, id);
   
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值