Initial implementation #3
No reviewers
Labels
No labels
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/zapjournald#3
Loading…
Reference in a new issue
No description provided.
Delete branch "AlekseySVTN/zapjournald:feature/0-initial_implementation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Signed-off-by: Aleksey Savaitan zxc_off@mail.ru
This is the first PR.
Commits with good "godoc" comments coming soon. May be already in this PR.
@ -0,0 +1,148 @@
# Zap Core for systemd Journal
Usually we name it
README.md
with uppercase in TrueCloudLab repos.fixed
@ -0,0 +8,4 @@
```go
package main
import (
Let's add an issue to simplify this example. I think we can remove parsing and setting of log level, date encoding, etc.
Issue was created: #4 +
@ -0,0 +75,4 @@
sudo journalctl -f
апр 04 12:23:38 aleksey-savaitan ___go_build_git_frostfs_info_TrueCloudLab_zapjournald_main[143813]: {"level":"info","ts":"2023-04-04T12:23:38.784+0300","msg":"Simple log raw 1","SYSLOG_FACILITY":3,"SYSLOG_IDENTIFIER":"___go_build_git_frostfs_info_TrueCloudLab_zapjournald_main","SYSLOG_PID":143813}
апр 04 12:23:38 aleksey-savaitan ___go_build_git_frostfs_info_TrueCloudLab_zapjournald_main[143813]: {"level":"error","ts":"2023-04-04T12:23:38.784+0300","msg":"Simple log raw 2","SYSLOG_FACILITY":3,"SYSLOG_IDENTIFIER":"___go_build_git_frostfs_info_TrueCloudLab_zapjournald_main","SYSLOG_PID":143813,"JUST":1}
```
Let's update results with setting 'LC_LANG=C' to avoid cyrillic dates and hide personal information like the name.
fixed
@ -0,0 +85,4 @@
#### Or you can read full-structured view like this:
```
sudo journalctl SYSLOG_PID=76385 --output=json-pretty
{
One log record is enough to demonstrate, I think.
fixed
@ -0,0 +1,153 @@
package zapjournald
Let's use one-word names for files. I think
zapjournald.go
andfields.go
looks better, but it is a matter of taste.fixed
@ -0,0 +8,4 @@
"golang.org/x/exp/maps"
)
// Core
It will be nice for all public structures and functions to be documented. Here we can mention, that
Core
is a structure that implementszap.Core
interface for logging into journald.You can use comments from interface definition here:
845ca51d5b/zapcore/core.go (L23-L44)
fixed
@ -0,0 +22,4 @@
const (
// Facility.
// From /usr/include/sys/syslog.h.
// These are the same up to LogFtp on Linux, BSD, and OS X.
These comments belongs to Facility type.
fixed
@ -0,0 +49,4 @@
LogLocal7
)
const LogFacmask = 0x03f8 /* mask to extract facility part */
or something like that.
fixed
@ -0,0 +51,4 @@
const LogFacmask = 0x03f8 /* mask to extract facility part */
var SyslogFields = []string{
Add a comment that this is a list of default indexed syslog fields
fixed
I think @alexvanin nailed it. Not much to add from my side.
@ -0,0 +108,4 @@
}
}
// getFieldValue - return interface-value of filled property of zapcore.Field
Go style suggests to format comments as proper sentences.
And linter prefers them with the period in the end :)
fixed
@ -0,0 +18,4 @@
"go.uber.org/zap/zapcore"
)
func main() {
What do you think about moving the example from README.md to a separate main.go file?
+1.
There is an example of example :) in the
frostfs-node
project: it stores sample configs in dedicated folder https://git.frostfs.info/TrueCloudLab/frostfs-node/src/branch/master/config/exampleBefore we have started to create library, we with Alex Vanin, Vladimir Domnich and Evgeniy Stratonikov decided to exclude main.go or example/example.log from library. But for me, it seems to be good to have something like that. So, I think, we should discuss it in new issue: #6
991e673754
to074fe474dd
@alexvanin , @vdomnich-yadro , @ironbee , @fyrchik , @dstepanov-yadro , @dkirillov
Please, look at this again, when you will have a time.
[#2] Initial implementationto Initial implementationWe still have some issues to do, but it looks like a good starting point.
A = attention.
I've just noticed that I am reviewing a merged PR 😅
@ -0,0 +51,4 @@
// LogFacmask is used to extract facility part of the message.
const LogFacmask = 0x03f8
// SyslogFields contains slice of fields that
->