| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

异步 C++ 日志框架:G3log

G3log 是一个开源、支持跨平台的异步 C++ 日志框架,支持自定义日志格式。基于 g2log 构建,提升了性能,支持自定义格式。

G3log 主要特性:

  • 日志和契约式设计框架

  • 异步调用

  • 线程安全

  • 队列式日志

  • 捕获和记录 SIGSEGV 以及其他严重的信号

  • 在 Linux/OSX 上严重的信号会生成堆栈记录

  • G3log 跨平台,支持  Windows, Linux 和 OSX

G3log 可使用 Visual Studio 2013, Clang 和 GCC4.7 构建。

EXAMPLE USAGE

Optional to use either streaming or printf-like syntax

LOG(INFO) << "streaming API is as easy as ABC or " << 123;    LOGF(WARNING, "Printf-style syntax is also %s", "available");

Conditional logging

int less = 1; int more = 2  LOG_IF(INFO, (less<more)) <<"If [true], then this text will be logged";    // or with printf-like syntax  LOGF_IF(INFO, (less<more), "if %d<%d then this text will be logged", less,more);

Design-by-Contract

CHECK(false) will trigger a "fatal" message. It will be logged, and then the application will exit.

CHECK(less != more); // not FATAL  CHECK(less > more) << "CHECK(false) triggers a FATAL message";

What G3Log is:

  • G3log is the acting name for the third version of g2log and it stands for g2log with dynamic sinks
  • G3log is an asynchronous, "crash-safe" logger. You can read more about it here [g2log version]
  • You can choose to use the default log receiver which saves all LOG calls to file, or you can choose to use your own custom made log receiver(s), or both, or as many sinks as you need.

Benefits you get when using G3log

  1. Easy to use, clean syntax and a blazing fast logger.

  2. All the slow log I/O disk access is done in a background thread. This ensures that the LOG caller can immediately continue with other tasks and do not have to wait for the LOG call to finish.

  3. G3log provides logging, Design-by-Contract [#CHECK], and flush of log to file at shutdown. Buffered logs will be written to the sink before the application shuts down.

  4. It is thread safe, so using it from multiple threads is completely fine.

  5. It is CRASH SAFE. It will save the made logs to the sink before it shuts down. The logger will catch certain fatal signals, so if your application crashes due to, say a segmentation fault, SIGSEGV, or some other fatal signal it will log and save the crash and all previously buffered log entries before exiting.

  6. It is cross platform. Tested and used by me or by clients on OSX, Windows, Ubuntu, CentOS

  7. On Nix systems a caught fatal signal will generate a stack dump to the log. A Beta version exist on Windows and can be released on request.

  8. G2log is used world wide in commercial products as well as hobby projects since early 2011. The code is given for free as public domain. This gives the option to change, use, and do whatever with it, no strings attached.

  9. Three versions of g2log exist.

    • This version: g3log : which is made to facilitate easy adding of custom log receivers. Its tested on at least the following platforms with Linux(Clang/gcc), Windows (mingw, visual studio 2013)
    • g2log: The original. Simple, easy to modify and with the most OS support. Clients use g2log on environments such as OSX/Clang, Ubuntu, CentOS, Windows/mingw, Windows/Visual Studio.
    • g2log-dev*: Acting as feature try-out and playground.

     

    项目主页:http://www.open-open.com/lib/view/home/1408677978459

     本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
     转载本站原创文章,请注明出处,并保留原始链接、图片水印。
     本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
     本文地址:https://www.open-open.com/lib/view/open1408677978459.html
    G3log 日志处理