欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件高级功能研发区 → [原创]4种预警方法

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有12492人关注过本帖平板打印复制链接

主题:[原创]4种预警方法

帅哥哟,离线,有人找我吗?
z7c9
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2016/1/5 22:27:35 [只看该作者]

#include <Poco/Logger.h>
#include <Poco/SplitterChannel.h>
#include <Poco/ConsoleChannel.h>
#include <Poco/FileChannel.h>
#include <Poco/FormattingChannel.h>
#include <Poco/PatternFormatter.h>
#include <Poco/AutoPtr.h>
#include <Poco/Util/PropertyFileConfiguration.h>
#include <Poco/Util/LoggingConfigurator.h>
#include <thread>

using namespace std;

using namespace Poco;
using namespace Poco::Util;

void config_logger(){
    AutoPtr<ConsoleChannel> console_channel(new ConsoleChannel);
    AutoPtr<FileChannel> file_channel(new FileChannel);
    file_channel->setProperty("path", "bingo.log");
    file_channel->setProperty("rotation", "daily");
    file_channel->setProperty("archive", "number");
    file_channel->setProperty("times", "local");
    file_channel->setProperty("purgeCount", "5");
    AutoPtr<SplitterChannel> splitter_channel(new SplitterChannel);

    splitter_channel->addChannel(console_channel);
    splitter_channel->addChannel(file_channel);

    AutoPtr<PatternFormatter> pattern_formatter(new PatternFormatter);
    pattern_formatter->setProperty("pattern", "[%Y-%m-%d %H:%M:%S][%s][%t]");
    pattern_formatter->setProperty("times", "local");


    AutoPtr<FormattingChannel> formatting_channel(new FormattingChannel);
    formatting_channel->setFormatter(pattern_formatter);
    formatting_channel->setChannel(splitter_channel);

    Logger::root().setChannel(formatting_channel);
}

void print1(){
    Logger &trade_log = Logger::get("Trade");

    for(int i = 0; i < 99; ++i){
        trade_log.information("000");
    }
}

void print2(){
    Logger &quote_log = Logger::get("Quote");

    for(int i = 0; i < 99; ++i){
        quote_log.information("111");
    }
}


int main(){
    config_logger();

    thread t1(print1);
    thread t2(print2);

    t1.join();
    t2.join();
}
		


 回到顶部
总数 18 1 2 下一页