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
02d1a95f
Commit
02d1a95f
authored
1 year ago
by
ko_oler
Browse files
Options
Downloads
Patches
Plain Diff
закомментирована функция convertInterfaceToAny
parent
7a20ca9f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/log/log.go
+10
-16
10 additions, 16 deletions
pkg/log/log.go
with
10 additions
and
16 deletions
pkg/log/log.go
+
10
−
16
View file @
02d1a95f
package
log
package
log
import
(
import
(
"encoding/json"
"time"
"time"
pb
"git.perx.ru/perxis/perxis-go/proto/log"
pb
"git.perx.ru/perxis/perxis-go/proto/log"
"github.com/golang/protobuf/ptypes/any"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/timestamppb"
wrappers
"google.golang.org/protobuf/types/known/wrapperspb"
)
)
type
Level
int
type
Level
int
...
@@ -44,15 +39,15 @@ type Entry struct {
...
@@ -44,15 +39,15 @@ type Entry struct {
Tags
[]
string
`json:"tags,omitempty" bson:"tags,omitempty"`
Tags
[]
string
`json:"tags,omitempty" bson:"tags,omitempty"`
}
}
func
convertInterfaceToAny
(
v
interface
{})
(
*
any
.
Any
,
error
)
{
//
func convertInterfaceToAny(v interface{}) (*any.Any, error) {
anyValue
:=
&
any
.
Any
{}
//
anyValue := &any.Any{}
bytes
,
_
:=
json
.
Marshal
(
v
)
//
bytes, _ := json.Marshal(v)
bytesValue
:=
&
wrappers
.
BytesValue
{
//
bytesValue := &wrappers.BytesValue{
Value
:
bytes
,
//
Value: bytes,
}
//
}
err
:=
anypb
.
MarshalFrom
(
anyValue
,
bytesValue
,
proto
.
MarshalOptions
{})
//
err := anypb.MarshalFrom(anyValue, bytesValue, proto.MarshalOptions{})
return
anyValue
,
err
//
return anyValue, err
}
//
}
func
EntryToPB
(
entry
*
Entry
)
*
pb
.
LogEntry
{
func
EntryToPB
(
entry
*
Entry
)
*
pb
.
LogEntry
{
logEntry
:=
&
pb
.
LogEntry
{
logEntry
:=
&
pb
.
LogEntry
{
...
@@ -65,10 +60,9 @@ func EntryToPB(entry *Entry) *pb.LogEntry {
...
@@ -65,10 +60,9 @@ func EntryToPB(entry *Entry) *pb.LogEntry {
Event
:
entry
.
Event
,
Event
:
entry
.
Event
,
Object
:
entry
.
Object
,
Object
:
entry
.
Object
,
Caller
:
entry
.
Caller
,
Caller
:
entry
.
Caller
,
Attr
:
nil
,
//implement
Tags
:
entry
.
Tags
,
Tags
:
entry
.
Tags
,
}
}
logEntry
.
Attr
,
_
=
convertInterfaceToAny
(
entry
.
Attr
)
return
logEntry
return
logEntry
}
}
...
...
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