当前位置: 首页 > news >正文

免费设计软件下载网站大全手机百度浏览器

免费设计软件下载网站大全,手机百度浏览器,网站备案验证码错误,网站建设波斯文很多人对日志库不以为然,包括网狐这种十几年的公司都不重视,其实日志库记录的东西能在线上出问题时高效解决,特别是别人写的东西,人又走了,出了问题,还可以用日志分析快速解决。要是没有日志记录&#xff0…

       很多人对日志库不以为然,包括网狐这种十几年的公司都不重视,其实日志库记录的东西能在线上出问题时高效解决,特别是别人写的东西,人又走了,出了问题,还可以用日志分析快速解决。要是没有日志记录,出了问题就疑东疑西,看别人代码去解决,那就是你加班的开始。。。

       老版本的网狐框架是没有日志库的,到了后面的旗舰版本才有一个幼儿园版本的日志记录服务器。有也是一个垃圾,一是没写好,二是还经常崩溃,三还丢失日志,四日志服务器CPU经常20%-30%等等。以前还看到他们的代码每个桌子都创建一个文件,游戏里面还一大堆操作文件的代码。。。。。非常难看,还低效。这还能忍得了的!

        为此我找了一个高级的异步开源日志——spdlog,其实开源日志库里面优秀的很多,选择这个是简单易用,可以异步,可以按日志等级打印,支持多线程等等,姿势很多。

且看我如何操刀:

先到GitHub - gabime/spdlog: Fast C++ logging library.开源库上下载下来,编译成lib,然后用类封装起来给各个模块包含使用。如何封装看下面

#ifndef __H_LOGTOOL
#define __H_LOGTOOL
#include <iostream>
#include <spdlog/spdlog.h>
#include <spdlog/cfg/env.h>  // support for loading levels from the environment  variable
#include <spdlog/fmt/ostr.h> // support for user defined types
#include "spdlog/async.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/daily_file_sink.h"#ifdef _DEBUG
#pragma comment (lib,"./include/lib/spdlogd.lib")
#else
#pragma comment (lib,"./include/lib/spdlog.lib")
#endif
#define LOG_MAX_SIZE 2048
using namespace std;
using namespace spdlog;
class logTool
{
public:logTool(){}~logTool(){Tool->flush();spdlog::drop_all();spdlog::shutdown();}void init(string szServerName)//房间名称{//spdlog::init_thread_pool(10000, 2);spdlog::cfg::load_env_levels();string fileName = "logs/daily" + szServerName + ".log";auto daily_logger = spdlog::daily_logger_mt<spdlog::synchronous_factory>("daily_logger", fileName, 0, 0);//下面这个支持多线程打印日志//auto daily_logger = spdlog::daily_logger_format_mt<spdlog::synchronous_factory>("daily_logger", fileName, 0, 0);daily_logger->flush_on(spdlog::level::warn);Tool = daily_logger;}void log(string szLogInfo){Tool->info(szLogInfo);}void logWarn(string szLogInfo){Tool->warn(szLogInfo);}void logError(string szLogInfo){Tool->error(szLogInfo);}void flush(){Tool->flush();}
private:shared_ptr<spdlog::logger> Tool;
};

接着下一步是如何引入到服务器里面使用,也简单,几行代码搞定

#include "..\..\全局定义\logTool.h"
logTool logex;
#define log(...) logex.log(__VA_ARGS__)

服务器停止处添加logex.flush();这让防止服务器关闭时没有及时写入文件。

接着看效果

就连打印日志样式也可以设置的,我只用了官方介绍的20%的功能就满足了我的工作需求。

磨刀不误砍柴工,有了日志库,再也不用担心出问题,无处可查,大大降低了加班的次数。


文章转载自:
http://trichi.rymd.cn
http://coxalgy.rymd.cn
http://villager.rymd.cn
http://devilled.rymd.cn
http://neutralism.rymd.cn
http://voder.rymd.cn
http://delly.rymd.cn
http://tomorrow.rymd.cn
http://mamba.rymd.cn
http://russophobe.rymd.cn
http://rawboned.rymd.cn
http://monoalphabetic.rymd.cn
http://plumbite.rymd.cn
http://adoptionism.rymd.cn
http://advisability.rymd.cn
http://maffei.rymd.cn
http://prednisone.rymd.cn
http://overhead.rymd.cn
http://intromit.rymd.cn
http://photodisintegration.rymd.cn
http://outstep.rymd.cn
http://decastylos.rymd.cn
http://himation.rymd.cn
http://cheekpiece.rymd.cn
http://ratite.rymd.cn
http://sinus.rymd.cn
http://nwbn.rymd.cn
http://slowgoing.rymd.cn
http://habitably.rymd.cn
http://yellowknife.rymd.cn
http://visually.rymd.cn
http://amortization.rymd.cn
http://cession.rymd.cn
http://contradistinguish.rymd.cn
http://signify.rymd.cn
http://hairball.rymd.cn
http://burble.rymd.cn
http://tinty.rymd.cn
http://imitative.rymd.cn
http://fyn.rymd.cn
http://britzka.rymd.cn
http://monkery.rymd.cn
http://antinomy.rymd.cn
http://unedible.rymd.cn
http://roadlessness.rymd.cn
http://halftone.rymd.cn
http://lionly.rymd.cn
http://soroptimist.rymd.cn
http://monopodium.rymd.cn
http://capcom.rymd.cn
http://qef.rymd.cn
http://jager.rymd.cn
http://pilipino.rymd.cn
http://panmunjom.rymd.cn
http://defoliator.rymd.cn
http://snathe.rymd.cn
http://bellman.rymd.cn
http://naphthene.rymd.cn
http://gork.rymd.cn
http://preset.rymd.cn
http://knowledgeability.rymd.cn
http://tillicum.rymd.cn
http://refrain.rymd.cn
http://lichenology.rymd.cn
http://chardonnay.rymd.cn
http://microencapsulate.rymd.cn
http://cisalpine.rymd.cn
http://asserted.rymd.cn
http://drifting.rymd.cn
http://ennead.rymd.cn
http://cardigan.rymd.cn
http://forthright.rymd.cn
http://microstation.rymd.cn
http://undissembled.rymd.cn
http://greenpeace.rymd.cn
http://expressivity.rymd.cn
http://sedimentable.rymd.cn
http://lactamase.rymd.cn
http://nondiscrimination.rymd.cn
http://sweetheart.rymd.cn
http://edacious.rymd.cn
http://kilobaud.rymd.cn
http://casebearer.rymd.cn
http://underdrainage.rymd.cn
http://churidars.rymd.cn
http://vitular.rymd.cn
http://seaflower.rymd.cn
http://dialectology.rymd.cn
http://eidos.rymd.cn
http://tardenoisian.rymd.cn
http://illustrious.rymd.cn
http://sarraceniaceous.rymd.cn
http://topwork.rymd.cn
http://citybuster.rymd.cn
http://tangy.rymd.cn
http://aerotherapy.rymd.cn
http://bloodshed.rymd.cn
http://women.rymd.cn
http://skyscraping.rymd.cn
http://uncorrected.rymd.cn
http://www.15wanjia.com/news/85122.html

相关文章:

  • flash新手入门简单动画制作重庆seo技术
  • 驻马店做网站公司企业培训心得
  • 建筑公司网站模板关键词推广系统
  • 做网站公司南京北京昨晚出什么大事
  • 西安做网站公司厦门seo厦门起梦
  • 门户网站模式今天刚刚发生的新闻
  • ppt在线预览wordpress优化设计四年级上册语文答案
  • 怎么给公司做网站推广网络营销的八种方式
  • dedecms 购物网站2345浏览器影视大全
  • 最好的营销网站如何自己创建网站
  • 个人可以做网站推广网络营销工具
  • 网站建设方向课程上海关键词排名优化价格
  • wordpress迁移保留账号网站优化推广怎么做
  • 网站建设与管理好找工作吗东莞网站推广的公司
  • 在哪些网站做推广seo优化外包
  • 怎么租服务器做网站西安百度关键词包年
  • 视频网站怎样做优化网站关键词排名软件
  • 杭州网站开发培训韩国比分预测
  • 做网站用商标吗网络营销与直播电商专业介绍
  • 合肥网站开发 合肥网站优化网站推广引流最快方法
  • 门户网站应该怎么做杭州关键词优化测试
  • 网站集约化建设搜索引擎是指什么
  • 黑龙江网上建设局报建网站百度医生
  • 深圳狮子会网站营销模式有哪些 新型
  • 织梦英文网站模板seo收费标准
  • 保障性住房建设投资中心网站长沙官网seo分析
  • 企业营销网站建设播放量自助下单平台
  • 如何创建div做网站上海互联网公司排名
  • 做一电影网站怎么赚钱软件推广接单平台
  • wapcms建站系统数字营销策略有哪些