Go to file
GergoTot 5323480780
Avoid pending of containerized applications in case of aborting (#481)
Improvement for Docker run C++ applications with g3log 

* This addresses the case when a PID1 process crashes and the signal handling, goes into multiple or even infinite loops due to subsequent crashes. The PR makes sure to restore all signal handlers to the original signal handling after the first crash is detected. For
2023-03-07 17:30:58 -07:00
.circleci Updated CI configurations and README that explained them (#436) 2022-03-07 21:44:22 -07:00
.github force check of stackdump (#475) 2023-02-04 04:37:13 -07:00
cmake fix(cmake): fixes #413 (#457) 2022-06-11 06:17:32 -06:00
docs __SIGFUNC__ no longer default for Windows. __PRETTY__FUNCTION no longer default for gcc/clang (#470) 2022-11-29 22:16:35 -07:00
example G3log placeholder thread ID formatting (#248) 2018-03-08 09:16:12 -07:00
scripts __SIGFUNC__ no longer default for Windows. __PRETTY__FUNCTION no longer default for gcc/clang (#470) 2022-11-29 22:16:35 -07:00
src Avoid pending of containerized applications in case of aborting (#481) 2023-03-07 17:30:58 -07:00
test_main g2log.hpp is kept as a helper include. It will pull in the most frequent include files 2015-07-16 01:55:23 -06:00
test_performance Fix several CMake Issues (#294) 2019-02-18 12:43:04 -07:00
test_unit Fix filesink drop messages improved (#479) 2023-02-20 06:16:34 -07:00
_config.yml Set theme jekyll-theme-cayman 2022-05-28 22:27:35 -06:00
.gitignore Use CMake to download GoogleTest as part of build (#355) 2020-06-03 15:37:46 -06:00
.hgrc_copy Added the .hgrc to easily switch between computer. 2014-10-10 01:19:38 -06:00
.hgtags Added tag version-1.0 for changeset d9a55a4a6154 2012-10-17 07:25:55 +02:00
appveyor.yml __SIGFUNC__ no longer default for Windows. __PRETTY__FUNCTION no longer default for gcc/clang (#470) 2022-11-29 22:16:35 -07:00
Build.cmake fix version (#404) 2021-04-08 21:44:33 -06:00
CleanAll.cmake CMake messages changed to message( STATUS "..." ) (#190) 2017-05-17 14:31:19 -06:00
CMakeLists.txt Fix filesink drop messages improved (#479) 2023-02-20 06:16:34 -07:00
CMakeLists.txt.in update gtest zip URL (#417) 2021-11-16 10:11:37 -07:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md (#411) 2021-07-07 15:55:50 -06:00
CONTRIBUTING.md updating for mkdocs generation 2022-05-28 21:13:54 -06:00
CPackLists.txt play/tryout: It is confusing to name the target g3logger. KISS --> g3log (#372) 2020-07-08 22:42:55 -06:00
GenerateMacroDefinitionsFile.cmake cmake: Avoid extra recompilation updating generated_definitions.hpp only if needed (#235) 2017-12-02 17:21:56 -07:00
iOS.cmake Add arm64e support (#307) 2019-03-14 22:10:58 -06:00
iOSBuild.cmake play/tryout: It is confusing to name the target g3logger. KISS --> g3log (#372) 2020-07-08 22:42:55 -06:00
LICENSE Added license and license referral to avoid any license confusion. G3log is a public domain dedication. Ref the unlicense.org 2014-07-03 15:42:19 -06:00
mkdocs.yml Update mkdocs.yml 2022-05-28 22:11:11 -06:00
Options.cmake __SIGFUNC__ no longer default for Windows. __PRETTY__FUNCTION no longer default for gcc/clang (#470) 2022-11-29 22:16:35 -07:00
PULL_REQUEST_TEMPLATE.md Update README.md (#456) 2022-05-29 04:24:55 -06:00
README.md Fix typo in README (#460) 2022-08-17 01:04:44 -06:00
sublime.formatting Making it easy for other people to see the formatting style 2015-07-16 01:58:21 -06:00

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.md. The internal API for more advanced integration with g3log can be accessed in API.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 happend, 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 both github actions and CircleCI for executing test coverage, installation and document generation. For windows the repo is still relying on appveyor. In case you want to look into change any of these setups the following files are the ones of interest.

1. appveyor --> g3log/appveyor.yml
2. circleCI --> g3log/.circleci/config.yml
3. github actions --> g3log/.github/workflows/*.yml


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