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
93e17dc6
Commit
93e17dc6
authored
1 year ago
by
ko_oler
Browse files
Options
Downloads
Patches
Plain Diff
Изменено название и значение констант событий в logging_middleware
parent
91301591
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
logs/zap/example_test.go
+4
-4
4 additions, 4 deletions
logs/zap/example_test.go
pkg/items/events.go
+8
-8
8 additions, 8 deletions
pkg/items/events.go
pkg/items/middleware/logging_middleware.go
+8
-8
8 additions, 8 deletions
pkg/items/middleware/logging_middleware.go
with
20 additions
and
20 deletions
logs/zap/example_test.go
+
4
−
4
View file @
93e17dc6
...
...
@@ -29,7 +29,7 @@ func TestExample(t *testing.T) {
Level
:
logs
.
Level
(
zapcore
.
InfoLevel
),
Message
:
"Successfully created"
,
Component
:
"Items"
,
Event
:
items
.
EventCreate
Item
,
Event
:
items
.
Event
Item
Create
,
ObjectID
:
id
.
MustObjectId
(
item
),
CallerID
:
id
.
MustObjectId
(
user
),
Tags
:
[]
string
{
"tag1"
,
"tag2"
,
"tag3"
},
...
...
@@ -38,7 +38,7 @@ func TestExample(t *testing.T) {
Level
:
logs
.
Level
(
zapcore
.
WarnLevel
),
Message
:
"Successfully updated"
,
Component
:
"Items"
,
Event
:
items
.
EventUpdate
Item
,
Event
:
items
.
Event
Item
Update
,
ObjectID
:
id
.
MustObjectId
(
item
),
CallerID
:
id
.
MustObjectId
(
user
),
Attr
:
map
[
string
]
map
[
string
]
any
{
"title"
:
{
"old"
:
"old title"
,
"new"
:
"new title"
}},
...
...
@@ -75,7 +75,7 @@ func TestExample(t *testing.T) {
// Отправка лога при создании item
logger
.
Info
(
"Successfully created"
,
logzap
.
Event
(
items
.
EventCreate
Item
),
logzap
.
Event
(
items
.
Event
Item
Create
),
logzap
.
Object
(
item
),
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Tags
(
"tag1"
,
"tag2"
,
"tag3"
),
...
...
@@ -83,7 +83,7 @@ func TestExample(t *testing.T) {
// Отправка лога при обновлении item
logger
.
Warn
(
"Successfully updated"
,
logzap
.
Event
(
items
.
EventUpdate
Item
),
logzap
.
Event
(
items
.
Event
Item
Update
),
logzap
.
Object
(
item
),
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Attr
(
map
[
string
]
map
[
string
]
any
{
"title"
:
{
"old"
:
"old title"
,
"new"
:
"new title"
}}),
...
...
This diff is collapsed.
Click to expand it.
pkg/items/events.go
+
8
−
8
View file @
93e17dc6
...
...
@@ -7,14 +7,14 @@ import (
)
const
(
EventCreate
Item
=
"create
_item
"
EventUpdate
Item
=
"update
_item
"
EventPublish
Item
=
"publish
_item
"
EventUnpublish
Item
=
"unpublish
_item
"
EventDelete
Item
=
"delete
_item
"
EventUndelete
Item
=
"item_undelete"
EventArchive
Item
=
"item_archive"
EventUnarchive
Item
=
"item_unarchive"
Event
Item
Create
=
"
item_
create"
Event
Item
Update
=
"
item_
update"
Event
Item
Publish
=
"
item_
publish"
Event
Item
Unpublish
=
"
item_
unpublish"
Event
Item
Delete
=
"
item_
delete"
Event
Item
Undelete
=
"item_undelete"
Event
Item
Archive
=
"item_archive"
Event
Item
Unarchive
=
"item_unarchive"
DefaultEventSubject
=
"content.{{.EventType}}.{{.SpaceID}}.{{.EnvID}}.{{.CollectionID}}.{{.ItemID}}"
)
...
...
This diff is collapsed.
Click to expand it.
pkg/items/middleware/logging_middleware.go
+
8
−
8
View file @
93e17dc6
...
...
@@ -55,7 +55,7 @@ func (m *loggingMiddleware) AggregatePublished(ctx context.Context, spaceId stri
func
(
m
*
loggingMiddleware
)
Archive
(
ctx
context
.
Context
,
item
*
items
.
Item
,
options
...*
items
.
ArchiveOptions
)
(
err
error
)
{
logger
:=
m
.
logger
.
With
(
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Event
(
items
.
EventArchive
Item
),
logzap
.
Event
(
items
.
Event
Item
Archive
),
logzap
.
Object
(
item
),
)
...
...
@@ -72,7 +72,7 @@ func (m *loggingMiddleware) Archive(ctx context.Context, item *items.Item, optio
func
(
m
*
loggingMiddleware
)
Create
(
ctx
context
.
Context
,
item
*
items
.
Item
,
opts
...*
items
.
CreateOptions
)
(
created
*
items
.
Item
,
err
error
)
{
logger
:=
m
.
logger
.
With
(
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Event
(
items
.
EventCreate
Item
),
logzap
.
Event
(
items
.
Event
Item
Create
),
)
created
,
err
=
m
.
next
.
Create
(
ctx
,
item
,
opts
...
)
...
...
@@ -88,7 +88,7 @@ func (m *loggingMiddleware) Create(ctx context.Context, item *items.Item, opts .
func
(
m
*
loggingMiddleware
)
Delete
(
ctx
context
.
Context
,
item
*
items
.
Item
,
options
...*
items
.
DeleteOptions
)
(
err
error
)
{
logger
:=
m
.
logger
.
With
(
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Event
(
items
.
EventDelete
Item
),
logzap
.
Event
(
items
.
Event
Item
Delete
),
logzap
.
Object
(
item
),
)
...
...
@@ -223,7 +223,7 @@ func (m *loggingMiddleware) ListRevisions(ctx context.Context, spaceId string, e
func
(
m
*
loggingMiddleware
)
Publish
(
ctx
context
.
Context
,
item
*
items
.
Item
,
options
...*
items
.
PublishOptions
)
(
err
error
)
{
logger
:=
m
.
logger
.
With
(
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Event
(
items
.
EventPublish
Item
),
logzap
.
Event
(
items
.
Event
Item
Publish
),
logzap
.
Object
(
item
),
)
...
...
@@ -240,7 +240,7 @@ func (m *loggingMiddleware) Publish(ctx context.Context, item *items.Item, optio
func
(
m
*
loggingMiddleware
)
Unarchive
(
ctx
context
.
Context
,
item
*
items
.
Item
,
options
...*
items
.
UnarchiveOptions
)
(
err
error
)
{
logger
:=
m
.
logger
.
With
(
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Event
(
items
.
EventUnarchive
Item
),
logzap
.
Event
(
items
.
Event
Item
Unarchive
),
logzap
.
Object
(
item
),
)
...
...
@@ -257,7 +257,7 @@ func (m *loggingMiddleware) Unarchive(ctx context.Context, item *items.Item, opt
func
(
m
*
loggingMiddleware
)
Undelete
(
ctx
context
.
Context
,
item
*
items
.
Item
,
options
...*
items
.
UndeleteOptions
)
(
err
error
)
{
logger
:=
m
.
logger
.
With
(
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Event
(
items
.
EventUndelete
Item
),
logzap
.
Event
(
items
.
Event
Item
Undelete
),
logzap
.
Object
(
item
),
)
...
...
@@ -274,7 +274,7 @@ func (m *loggingMiddleware) Undelete(ctx context.Context, item *items.Item, opti
func
(
m
*
loggingMiddleware
)
Unpublish
(
ctx
context
.
Context
,
item
*
items
.
Item
,
options
...*
items
.
UnpublishOptions
)
(
err
error
)
{
logger
:=
m
.
logger
.
With
(
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Event
(
items
.
EventUnpublish
Item
),
logzap
.
Event
(
items
.
Event
Item
Unpublish
),
logzap
.
Object
(
item
),
)
...
...
@@ -291,7 +291,7 @@ func (m *loggingMiddleware) Unpublish(ctx context.Context, item *items.Item, opt
func
(
m
*
loggingMiddleware
)
Update
(
ctx
context
.
Context
,
item
*
items
.
Item
,
options
...*
items
.
UpdateOptions
)
(
err
error
)
{
logger
:=
m
.
logger
.
With
(
logzap
.
CallerFromContext
(
ctx
),
logzap
.
Event
(
items
.
EventUpdate
Item
),
logzap
.
Event
(
items
.
Event
Item
Update
),
logzap
.
Object
(
item
),
)
...
...
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