The Unlicense

项目介绍

KjellKod/g3log 是一个托管在 GitHub 上的开源项目,主要使用 C++ 编写,采用 The Unlicense 许可证,目前获得 966 个 Star、280 次 Fork。

仓库全名
KjellKod/g3log
开源许可证
The Unlicense
Star 数
966
Fork 数
280
未关闭 Issue
1

README 摘要

Contents introduction | detailed information | Configure & Build | API description | Custom log formatting Welcome to g3log Use kjellkod.github.io/g3log/ for best reading / searching / navigating of g3log's documentation G3log is an asynchronous logger with three main features: 1. Intuitive LOG(...) API 2. Design-by-contract CHECK(...) functionality 3. Fatal crash handling for graceful shutdown of the logged process…

完整内容见 GitHub 原始 README 或本页 。

常见问题

g3log 用什么语言开发?

主要使用 C++ 编写,采用 The Unlicense 许可证,目前有 966 个 Star。

g3log 可以免费商用吗?

仓库采用 The Unlicense 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 g3log 的源码?

可以直接克隆仓库:git clone https://github.com/KjellKod/g3log.git,默认分支为 master;安装与运行步骤见仓库 README。

g3log 最近还在维护吗?

仓库最近一次更新为 6 天前,当前有 1 个未关闭 Issue;Star 数为 966,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

G3log is an asynchronous, "crash safe", logger that is easy to use with default logging sinks or you can add your own. G3log is made with plain C++14 (C++11 support up to release 1.3.2) with no external libraries (except gtest used for unit tests). G3log is made to be cross-platform, currently running on OSX, Windows and several Linux distros. See Readme below for details of usage.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1575
价值分
668
活跃状态
活跃

语言占比

C++
CMake
Dockerfile
Shell

README

Scanning Update: ci/action CodeQL

Contents

introduction | detailed information | Configure & Build | API description | Custom log formatting

Welcome to g3log

Use kjellkod.github.io/g3log/ for best reading / searching / navigating of g3log’s documentation

G3log is an asynchronous logger with three main features:

  1. Intuitive LOG(...) API
  2. Design-by-contract CHECK(...) functionality
  3. Fatal crash handling for graceful shutdown of the logged process without loosing any log details up to the point of the crash.

The super quick introduction to g3log can be seen in the steps 1 - 9 below.

For more in-depth information please see the full usage description in g3log_usage.md. If you want to understand better the internals of g3log, then plase look at the API.md for both high-level and deep-dive insights.

Experiment and try-out g3log in Github Codespaces

ref: codespaces.md

1. Easy usage in files

Avoid deep dependency injection complexity and instead get access to the logger as easy as:

#include <g3log/g3log.hpp>

2. Access to streaming and print_f log call syntax

Both streaming syntax LOG and print_f LOGF syntax are available:

LOGF(INFO, "Hi log %d", 123);
LOG(INF) << "Hi log " << 123;

3. Conditional logging

LOG_IF(INFO, (1 < 2)) << "If true this message will be logged";
LOGF_IF(INFO, (1 < 2), "If true, then this %s will be logged", "message");

4. Design-by-contract framework

CHECK(less != more); // not fatal
CHECK_F(less > more, "CHECK(false) will trigger a fatal message")

5. Handling of fatal

By default g3log will capture fatal events such as LOG(FATAL), CHECK(false) and otherwise fatal signals such as:

    SIGABRT
    SIGFPE
    SIGILL
    SIGSEGV
    SIGTERM

When a fatal event happens the not-yet written log activity will be flushed to the logging sinks. Only when all logging activity up to the point of the fatal event has happened, will g3log allow the fatal event to proceed and exit the process.

If object symbols are available the fatal handler will attempt to push the stacktrace up to the fatal reason to the logging sink.

5b. Overriding and customization of fatal event handling

For overriding fatal error handling to use your own, or to add code hooks that you want to execute please see the API.md doc.

6. Default and Custom logging levels

The default logging levels are DEBUG, INFO, WARNING and FATAL. You can define your own logging levels or completely replace the logging levels. Ref: API.md

7. Log filtering

Log filtering is handled in g3log if dynamic logging levels are enabled in the configuration. See the API.md for information. Log filtering can also be handled through the sink as can be seen in github/Kjellod/g3sinks

8. 3rd party and custom logging sinks

The default logging sink has no external 3rd party dependencies. For more logging sinks please see github/Kjellod/g3sinks

  • log rotate
  • log to syslog
  • log to colored terminal output
  • log rotate with filter

See the API.md for more information about the simple steps to creating your own logging sink.

9. Log instantiation

With the default application name left as is (i.e. “g3log”) a creation of the logger could look something like this:

  const std::string directory = "./";
  const std::string name = "TestLogFile";
  auto worker = g3::LogWorker::createLogWorker();
  auto handle = worker->addDefaultLogger(name, directory);

The resulting filename would be something like:

   ./TestLogFile.g3log.20160217-001406.log

Performance

G3log aims to keep all background logging to sinks with as little log overhead as possible to the logging sink and with as small “worst case latency” as possible. For this reason g3log is a good logger for many systems that deal with critical tasks. Depending on platform the average logging overhead will differ. On my 2010 laptop the average call, when doing extreme performance testing, will be about ~2 us.

The worst case latency is kept stable with no extreme peaks, in spite of any sudden extreme pressure. I have a blog post regarding comparing worst case latency for g3log and other loggers which might be of interest. You can find it here: https://kjellkod.wordpress.com/2015/06/30/the-worlds-fastest-logger-vs-g3log/

Continuous Integration

The g3log repository is evaluating github actions for executing test coverage, installation and document generation. In case you want to look into change any of these setups the following files are the ones of interest. See Actions for matrix (ubuntu, macos, windows) testing as well as other actions for doc publishing.

Feedback

If you like this logger (or not) it would be nice with some feedback. That way I can improve g3log and it is always nice to hear when and how someone is using it.

If you have ANY questions or problems please do not hesitate in contacting me at Hedstrom @ Kjellod. cc

Say Thanks

This logger is available for free and all of its source code is public domain. A great way of saying thanks is to send a donation. It would go a long way not only to show your support but also to boost continued development.

Donate

  • $5 for a cup of coffee
  • $25 for a late evening coding with takeout

Cheers

Kjell (a.k.a. KjellKod)

introduction | detailed information | Configure & Build | API description | Custom log formatting

评论

暂无评论