nspcc-dev / neo-go

Go Node and SDK for the NEO blockchain
MIT License
120 stars 78 forks source link

move log level inside logging system #3474

Open 532910 opened 3 months ago

532910 commented 3 months ago
% journalctl -u neofs-storage.service -p err      
-- No entries --

The No entries is wrong answer, because there are:

% journalctl -u neofs-storage.service | grep error | wc -l
123998
roman-khimov commented 3 months ago

That's called severity. I thought it works fine, but if we're catching these lines from stdout then journald docs should be checked for possibility of severity detection from them.

532910 commented 3 months ago

That's called severity

in syslog

in systemd it's priority: https://manpages.debian.org/bookworm/systemd/journalctl.1.en.html

-p, --priority= Filter output by message priorities or priority ranges. Takes either a single numeric or textual log level (i.e. between 0/"emerg" and 7/"debug"), or a range of numeric/text log levels in the form FROM..TO. The log levels are the usual syslog log levels as documented in syslog(3), i.e. "emerg" (0), "alert" (1), "crit" (2), "err" (3), "warning" (4), "notice" (5), "info" (6), "debug" (7). If a single log level is specified, all messages with this log level or a lower (hence more important) log level are shown. If a range is specified, all messages within the range are shown, including both the start and the end value of the range. This will add "PRIORITY=" matches for the specified priorities.

roman-khimov commented 3 months ago

I doubt zap can do prefixes like in https://www.freedesktop.org/software/systemd/man/latest/sd-daemon.html. It also doesn't have a proper set of severities/priorities/levels.

532910 commented 3 months ago

https://git.frostfs.info/TrueCloudLab/zapjournald it was the first link by google(go zap journald)

532910 commented 3 months ago

also journald is supported by zap: https://pkg.go.dev/go.pact.im/x/zapjournal

roman-khimov commented 3 months ago

https://git.frostfs.info/TrueCloudLab/zapjournald

That one solves a different problem, but maybe can be extended to handle levels in some way.

https://pkg.go.dev/go.pact.im/x/zapjournal

Also different.

There are two problems here:

fyfyrchik commented 3 months ago

https://git.frostfs.info/TrueCloudLab/zapjournald

We have tried it (actually, have written), so I will just outline some problems we have encountered:

  1. Zap is famous for being zero-alloc and fast, it was harder to achieve this with zapjournald (we still have 1 alloc for trivial cases, but this is because of our requirement to have other native journal fields without them being used as application-level fields). In neo-go, it could be made zero-alloc.
  2. We have reverted the change in one of our services, because custom journal sink for zap had random slowdowns (likely related to journald itself, still investigating).