Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
63f97b51
Commit
63f97b51
authored
1 year ago
by
Semyon Krestyaninov
Browse files
Options
Downloads
Patches
Plain Diff
fix tests
parent
6e41358f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
logs/zap/core.go
+3
-1
3 additions, 1 deletion
logs/zap/core.go
logs/zap/entry_encoder.go
+12
-6
12 additions, 6 deletions
logs/zap/entry_encoder.go
with
15 additions
and
7 deletions
logs/zap/core.go
+
3
−
1
View file @
63f97b51
...
@@ -28,10 +28,12 @@ func NewCore(writeSyncer WriteSyncer) *Core {
...
@@ -28,10 +28,12 @@ func NewCore(writeSyncer WriteSyncer) *Core {
}
}
func
(
core
*
Core
)
With
(
fields
[]
zapcore
.
Field
)
zapcore
.
Core
{
func
(
core
*
Core
)
With
(
fields
[]
zapcore
.
Field
)
zapcore
.
Core
{
enc
:=
core
.
enc
.
Clone
()
enc
.
AddFields
(
fields
)
return
&
Core
{
return
&
Core
{
LevelEnabler
:
core
.
LevelEnabler
,
LevelEnabler
:
core
.
LevelEnabler
,
ws
:
core
.
ws
,
ws
:
core
.
ws
,
enc
:
core
.
enc
.
With
(
fields
)
,
enc
:
enc
,
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
logs/zap/entry_encoder.go
+
12
−
6
View file @
63f97b51
...
@@ -12,7 +12,8 @@ import (
...
@@ -12,7 +12,8 @@ import (
)
)
type
Encoder
interface
{
type
Encoder
interface
{
With
([]
zapcore
.
Field
)
Encoder
Clone
()
Encoder
AddFields
([]
zapcore
.
Field
)
EncodeEntry
(
zapcore
.
Entry
,
[]
zapcore
.
Field
)
(
*
logs
.
Entry
,
error
)
EncodeEntry
(
zapcore
.
Entry
,
[]
zapcore
.
Field
)
(
*
logs
.
Entry
,
error
)
}
}
...
@@ -24,12 +25,16 @@ func NewEntryEncoder() Encoder {
...
@@ -24,12 +25,16 @@ func NewEntryEncoder() Encoder {
return
&
entryEncoder
{}
return
&
entryEncoder
{}
}
}
func
(
enc
*
entryEncoder
)
With
(
fields
[]
zapcore
.
Field
)
Encoder
{
func
(
enc
*
entryEncoder
)
AddFields
(
fields
[]
zapcore
.
Field
)
{
return
enc
.
with
(
fields
)
enc
.
fields
=
slices
.
Concat
(
enc
.
fields
,
fields
)
}
}
func
(
enc
*
entryEncoder
)
with
(
fields
[]
zapcore
.
Field
)
*
entryEncoder
{
func
(
enc
*
entryEncoder
)
Clone
()
Encoder
{
return
&
entryEncoder
{
fields
:
slices
.
Concat
(
enc
.
fields
,
fields
)}
return
enc
.
clone
()
}
func
(
enc
*
entryEncoder
)
clone
()
*
entryEncoder
{
return
&
entryEncoder
{
fields
:
slices
.
Clone
(
enc
.
fields
)}
}
}
func
(
enc
*
entryEncoder
)
EncodeEntry
(
entry
zapcore
.
Entry
,
fields
[]
zapcore
.
Field
)
(
*
logs
.
Entry
,
error
)
{
func
(
enc
*
entryEncoder
)
EncodeEntry
(
entry
zapcore
.
Entry
,
fields
[]
zapcore
.
Field
)
(
*
logs
.
Entry
,
error
)
{
...
@@ -40,7 +45,8 @@ func (enc *entryEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field
...
@@ -40,7 +45,8 @@ func (enc *entryEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Field
Message
:
entry
.
Message
,
Message
:
entry
.
Message
,
}
}
clone
:=
enc
.
with
(
fields
)
clone
:=
enc
.
clone
()
clone
.
AddFields
(
fields
)
for
i
:=
range
clone
.
fields
{
for
i
:=
range
clone
.
fields
{
switch
clone
.
fields
[
i
]
.
Key
{
switch
clone
.
fields
[
i
]
.
Key
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment