Coder Social home page Coder Social logo

logger's Introduction

基本信息

  • 创建时间:2020-04-08
  • 项目内容:基于Boost构建的一个LOG库
  • 项目出发点:C++也有一些日志库(如:GLOG, Log4j的C++版本,...),Boost本身也支持日志,但是GLOG要额外配置,Log4j原本是Java的,也需要额外配置,Boost自带的日志接口有些用户门槛,所以这里对其进行了封装,实现了如下功能

功能点一:同步和异步无缝切换

  • 通过logging.h文件夹中的USING_ASYNC_LOG_MODE作为切换的开关
  • 同步的好处:日志不会丢
  • 异步的好处:速度快但是可能会丢日志(之前的测试为:同步约6.3ms -> 异步0.3ms)

功能点二:直接logger_xxx调用不同level的日志打印宏

  • 经过反复的探索,发现还是宏输出的方式最适合C++: LOGGER_XXX << "LOGGER INFO ...."
    • GLOGBOOST本身也使用可这种方式
  • 宏输出也方便了__LINE__,__FILE__,__FUNCTION__信息的打印,方便定位问题

功能点三:实现了日志切割逻辑

  • 利用BOOSTlogging::sinks::text_multifile_backend的特点实现了日志自动切割

其它

  • 编译的环境是VS Code + CMake来实现跨平台的;参考这里
  • VS Code.vscde下的launch.jsontasks.json实现了编译器可选
  • CMake实现了跨平台编译
  • Boost的安装:相较于其它的开源库的编译和安装Boost已经是非常的简单了,网上也有很多资料,查查就会了,例如:这里

使用说明

  • git clone代码
  • VScode按照这里配置好
  • 安装上Boost
  • VSCode中按F5按照提示一路next

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.