Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New source code logger #110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions logging/new_logger
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# New source code logger

## Current logger

* fc::logger
** Console logging both stderr & stdout
** GELF logging
** Deep-mind logging to a file
** Works with fc::variant for logging any FC_REFLECT type

Could enhance fc::logger to add file support, file rotation, async logging, filtering, etc. OR switch to a third-party open source logger.

## New logger

Evaluate existing open source log libraries. `spdlog` (https://github.com/gabime/spdlog) has been used by core team in the past on other projects.

## Integration

`spdlog` uses `fmt` library which is part of C++20 or is available as a separate third-party library (https://github.com/fmtlib/fmt).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is part of c++20 but sadly is still not present in the latest versions of libstdc++ nor libc++, so realistically we'll need to use the third party library for the next 4+ years.

Copy link

@greg7mdp greg7mdp Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so realistically we'll need to use the third party library for the next 4+ years.

Seems to me that it would be better than the alternative (of not using std::format or fmtlib)

The switch to `fmt` instead of `fc::variant` will require providing a mapping between FC_REFLECT and `fmt`.
A start of that work can be found at
* https://github.com/EOSIO/fc/tree/kjh-epe-291-fc
* https://github.com/EOSIO/fc/commits/jjz-epe-2012-new-logging-library-fc
* https://github.com/EOSIO/eos/tree/kjh-epe-291-log

Existing fc_xlog macros could be updated to use `spdlog` or just use spdlog macros directly.

`spdlog` does not include a GELF logger. However, since our current GELF logger is hand-written it should be simple enough to add a new sink type to `spdlog`.