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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
ed945bc7
Commit
ed945bc7
authored
1 year ago
by
Semyon Krestyaninov
Browse files
Options
Downloads
Patches
Plain Diff
remove field validation
parent
9cbfa2e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zap/field.go
+2
-26
2 additions, 26 deletions
zap/field.go
with
2 additions
and
26 deletions
zap/field.go
+
2
−
26
View file @
ed945bc7
...
...
@@ -15,64 +15,40 @@ func Channel(channels ...string) zap.Field {
}
func
Category
(
category
string
)
zap
.
Field
{
if
category
==
""
{
return
zap
.
Skip
()
}
return
zap
.
String
(
"category"
,
category
)
}
func
Component
(
component
string
)
zap
.
Field
{
if
component
==
""
{
return
zap
.
Skip
()
}
return
zap
.
String
(
"component"
,
component
)
}
func
Event
(
event
string
)
zap
.
Field
{
if
event
==
""
{
return
zap
.
Skip
()
}
return
zap
.
String
(
"event"
,
event
)
}
// Object возвращает поле и устанавливает передаваемый аргумент в качестве идентификатора объекта в формате ObjectId.
// Поддерживает типы в формате ObjectId: id.Descriptor, string, map[string]any, системные объекты.
func
Object
(
v
any
)
zap
.
Field
{
oid
,
err
:=
id
.
NewObjectId
(
v
)
if
err
!=
nil
{
return
zap
.
Skip
()
}
oid
,
_
:=
id
.
NewObjectId
(
v
)
return
zap
.
Reflect
(
"object"
,
oid
)
}
// Caller возвращает поле и устанавливает передаваемый аргумент в качестве "вызывающего" в формате ObjectId.
// Поддерживает типы в формате ObjectId: id.Descriptor, string, map[string]any, системные объекты.
func
Caller
(
v
any
)
zap
.
Field
{
oid
,
err
:=
id
.
NewObjectId
(
v
)
if
err
!=
nil
{
return
zap
.
Skip
()
}
oid
,
_
:=
id
.
NewObjectId
(
v
)
return
zap
.
Reflect
(
"caller"
,
oid
)
}
// CallerFromContext извлекает auth.Principal из контекста и устанавливает его в качестве "вызывающего" в формате Object.
func
CallerFromContext
(
ctx
context
.
Context
)
zap
.
Field
{
if
ctx
==
nil
{
return
zap
.
Skip
()
}
return
Caller
(
auth
.
GetPrincipal
(
ctx
))
}
func
Attr
(
attr
any
)
zap
.
Field
{
if
attr
==
nil
{
return
zap
.
Skip
()
}
return
zap
.
Any
(
"attr"
,
attr
)
}
func
Tags
(
tags
...
string
)
zap
.
Field
{
if
len
(
tags
)
==
0
{
return
zap
.
Skip
()
}
return
zap
.
Strings
(
"tags"
,
tags
)
}
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