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
e00f45e5
Commit
e00f45e5
authored
1 year ago
by
Semyon Krestyaninov
Browse files
Options
Downloads
Patches
Plain Diff
refactor
parent
ff905f68
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
log/zap/buffered_write_syncer_test.go
+2
-2
2 additions, 2 deletions
log/zap/buffered_write_syncer_test.go
log/zap/core.go
+2
-2
2 additions, 2 deletions
log/zap/core.go
log/zap/core_test.go
+5
-4
5 additions, 4 deletions
log/zap/core_test.go
log/zap/example_test.go
+13
-9
13 additions, 9 deletions
log/zap/example_test.go
with
22 additions
and
17 deletions
log/zap/buffered_write_syncer_test.go
+
2
−
2
View file @
e00f45e5
...
@@ -5,8 +5,8 @@ import (
...
@@ -5,8 +5,8 @@ import (
"testing"
"testing"
"time"
"time"
"git.perx.ru/perxis/perxis-go/
pkg/
log"
"git.perx.ru/perxis/perxis-go/log"
logmocks
"git.perx.ru/perxis/perxis-go/
pkg/
log/mocks"
logmocks
"git.perx.ru/perxis/perxis-go/log/mocks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
...
...
This diff is collapsed.
Click to expand it.
log/zap/core.go
+
2
−
2
View file @
e00f45e5
...
@@ -72,8 +72,8 @@ func (core *Core) getEntry(entry zapcore.Entry, fields []zapcore.Field) *log.Ent
...
@@ -72,8 +72,8 @@ func (core *Core) getEntry(entry zapcore.Entry, fields []zapcore.Field) *log.Ent
ent
.
Category
,
_
=
enc
.
Fields
[
"category"
]
.
(
string
)
ent
.
Category
,
_
=
enc
.
Fields
[
"category"
]
.
(
string
)
ent
.
Component
,
_
=
enc
.
Fields
[
"component"
]
.
(
string
)
ent
.
Component
,
_
=
enc
.
Fields
[
"component"
]
.
(
string
)
ent
.
Event
,
_
=
enc
.
Fields
[
"event"
]
.
(
string
)
ent
.
Event
,
_
=
enc
.
Fields
[
"event"
]
.
(
string
)
ent
.
ObjectID
,
_
=
enc
.
Fields
[
"object"
]
.
(
*
oid
.
ObjectId
)
ent
.
ObjectID
,
_
=
enc
.
Fields
[
"object
_id
"
]
.
(
*
oid
.
ObjectId
)
ent
.
CallerID
,
_
=
enc
.
Fields
[
"caller"
]
.
(
*
oid
.
ObjectId
)
ent
.
CallerID
,
_
=
enc
.
Fields
[
"caller
_id
"
]
.
(
*
oid
.
ObjectId
)
ent
.
Attr
=
enc
.
Fields
[
"attr"
]
ent
.
Attr
=
enc
.
Fields
[
"attr"
]
if
tags
,
ok
:=
enc
.
Fields
[
"tags"
]
.
([]
any
);
ok
{
if
tags
,
ok
:=
enc
.
Fields
[
"tags"
]
.
([]
any
);
ok
{
...
...
This diff is collapsed.
Click to expand it.
log/zap/core_test.go
+
5
−
4
View file @
e00f45e5
...
@@ -3,6 +3,7 @@ package zap
...
@@ -3,6 +3,7 @@ package zap
import
(
import
(
"testing"
"testing"
"git.perx.ru/perxis/perxis-go/id"
"git.perx.ru/perxis/perxis-go/log"
"git.perx.ru/perxis/perxis-go/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap"
...
@@ -32,8 +33,8 @@ func TestCore_getEntry(t *testing.T) {
...
@@ -32,8 +33,8 @@ func TestCore_getEntry(t *testing.T) {
Category
(
"create"
),
Category
(
"create"
),
Component
(
"Items.Service"
),
Component
(
"Items.Service"
),
Event
(
"Items.Create"
),
Event
(
"Items.Create"
),
Object
(
"/spaces/WPNN/envs/9VGP/cols/GxNv/items/W0fl"
),
Object
ID
(
"/spaces/WPNN/envs/9VGP/cols/GxNv/items/W0fl"
),
Caller
(
"/users/PHVz"
),
Caller
ID
(
"/users/PHVz"
),
Attr
(
"any"
),
Attr
(
"any"
),
Tags
(
"tag1"
,
"tag2"
,
"tag3"
),
Tags
(
"tag1"
,
"tag2"
,
"tag3"
),
},
},
...
@@ -44,8 +45,8 @@ func TestCore_getEntry(t *testing.T) {
...
@@ -44,8 +45,8 @@ func TestCore_getEntry(t *testing.T) {
Category
:
"create"
,
Category
:
"create"
,
Component
:
"Items.Service"
,
Component
:
"Items.Service"
,
Event
:
"Items.Create"
,
Event
:
"Items.Create"
,
ObjectID
:
"/spaces/WPNN/envs/9VGP/cols/GxNv/items/W0fl"
,
ObjectID
:
id
.
MustObjectId
(
"/spaces/WPNN/envs/9VGP/cols/GxNv/items/W0fl"
)
,
CallerID
:
"/users/PHVz"
,
CallerID
:
id
.
MustObjectId
(
"/users/PHVz"
)
,
Attr
:
"any"
,
Attr
:
"any"
,
Tags
:
[]
string
{
"tag1"
,
"tag2"
,
"tag3"
},
Tags
:
[]
string
{
"tag1"
,
"tag2"
,
"tag3"
},
},
},
...
...
This diff is collapsed.
Click to expand it.
log/zap/example_test.go
+
13
−
9
View file @
e00f45e5
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"slices"
"slices"
"testing"
"testing"
"git.perx.ru/perxis/perxis-go/id"
"git.perx.ru/perxis/perxis-go/log"
"git.perx.ru/perxis/perxis-go/log"
logmocks
"git.perx.ru/perxis/perxis-go/log/mocks"
logmocks
"git.perx.ru/perxis/perxis-go/log/mocks"
"git.perx.ru/perxis/perxis-go/pkg/auth"
"git.perx.ru/perxis/perxis-go/pkg/auth"
...
@@ -19,14 +20,17 @@ import (
...
@@ -19,14 +20,17 @@ import (
)
)
func
TestExample
(
t
*
testing
.
T
)
{
func
TestExample
(
t
*
testing
.
T
)
{
item
:=
items
.
NewItem
(
"WPNN"
,
"9VGP"
,
"GxNv"
,
"W0fl"
,
nil
,
nil
)
user
:=
&
users
.
User
{
ID
:
"294de355"
}
wantEntries
:=
[]
*
log
.
Entry
{
wantEntries
:=
[]
*
log
.
Entry
{
{
{
LogLevel
:
log
.
Level
(
zapcore
.
InfoLevel
),
LogLevel
:
log
.
Level
(
zapcore
.
InfoLevel
),
Message
:
"Successfully created"
,
Message
:
"Successfully created"
,
Component
:
"Items"
,
Component
:
"Items"
,
Event
:
items
.
EventCreateItem
,
Event
:
items
.
EventCreateItem
,
ObjectID
:
"/spaces/WPNN/envs/9VGP/cols/GxNv/items/W0fl"
,
ObjectID
:
id
.
MustObjectId
(
item
)
,
CallerID
:
"/users/294de355"
,
CallerID
:
id
.
MustObjectId
(
user
)
,
Tags
:
[]
string
{
"tag1"
,
"tag2"
,
"tag3"
},
Tags
:
[]
string
{
"tag1"
,
"tag2"
,
"tag3"
},
},
},
{
{
...
@@ -34,8 +38,8 @@ func TestExample(t *testing.T) {
...
@@ -34,8 +38,8 @@ func TestExample(t *testing.T) {
Message
:
"Successfully updated"
,
Message
:
"Successfully updated"
,
Component
:
"Items"
,
Component
:
"Items"
,
Event
:
items
.
EventUpdateItem
,
Event
:
items
.
EventUpdateItem
,
ObjectID
:
"/spaces/WPNN/envs/9VGP/cols/GxNv/items/cmV2cw"
,
ObjectID
:
id
.
MustObjectId
(
item
)
,
CallerID
:
"/users/294de355"
,
CallerID
:
id
.
MustObjectId
(
user
)
,
Attr
:
map
[
string
]
map
[
string
]
any
{
"title"
:
{
"old"
:
"old title"
,
"new"
:
"new title"
}},
Attr
:
map
[
string
]
map
[
string
]
any
{
"title"
:
{
"old"
:
"old title"
,
"new"
:
"new title"
}},
},
},
}
}
...
@@ -56,7 +60,7 @@ func TestExample(t *testing.T) {
...
@@ -56,7 +60,7 @@ func TestExample(t *testing.T) {
Once
()
Once
()
usersService
:=
&
usersmocks
.
Users
{}
usersService
:=
&
usersmocks
.
Users
{}
usersService
.
On
(
"GetByIdentity"
,
mock
.
Anything
,
"74d90aaf"
)
.
Return
(
&
user
s
.
User
{
ID
:
"294de355"
}
,
nil
)
.
Once
()
usersService
.
On
(
"GetByIdentity"
,
mock
.
Anything
,
"74d90aaf"
)
.
Return
(
user
,
nil
)
.
Once
()
factory
:=
auth
.
PrincipalFactory
{
Users
:
usersService
}
factory
:=
auth
.
PrincipalFactory
{
Users
:
usersService
}
...
@@ -71,16 +75,16 @@ func TestExample(t *testing.T) {
...
@@ -71,16 +75,16 @@ func TestExample(t *testing.T) {
// Отправка лога при создании item
// Отправка лога при создании item
logger
.
Info
(
"Successfully created"
,
logger
.
Info
(
"Successfully created"
,
Event
(
items
.
EventCreateItem
),
Event
(
items
.
EventCreateItem
),
Object
(
item
s
.
NewItem
(
"WPNN"
,
"9VGP"
,
"GxNv"
,
"W0fl"
,
nil
,
nil
)
),
Object
ID
(
item
),
CallerFromContext
(
ctx
),
Caller
ID
FromContext
(
ctx
),
Tags
(
"tag1"
,
"tag2"
,
"tag3"
),
Tags
(
"tag1"
,
"tag2"
,
"tag3"
),
)
)
// Отправка лога при обновлении item
// Отправка лога при обновлении item
logger
.
Warn
(
"Successfully updated"
,
logger
.
Warn
(
"Successfully updated"
,
Event
(
items
.
EventUpdateItem
),
Event
(
items
.
EventUpdateItem
),
Object
(
item
s
.
NewItem
(
"WPNN"
,
"9VGP"
,
"GxNv"
,
"cmV2cw"
,
nil
,
nil
)
),
Object
ID
(
item
),
CallerFromContext
(
ctx
),
Caller
ID
FromContext
(
ctx
),
Attr
(
map
[
string
]
map
[
string
]
any
{
"title"
:
{
"old"
:
"old title"
,
"new"
:
"new title"
}}),
Attr
(
map
[
string
]
map
[
string
]
any
{
"title"
:
{
"old"
:
"old title"
,
"new"
:
"new title"
}}),
)
)
}
}
...
...
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