Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
8a1708f0
Unverified
Commit
8a1708f0
authored
8 years ago
by
Silas Davis
Browse files
Options
Downloads
Patches
Plain Diff
document structure a bit better
parent
cb1ffca5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
logging/adapters/tendermint_log15/convert.go
+5
-6
5 additions, 6 deletions
logging/adapters/tendermint_log15/convert.go
logging/structure/structure.go
+6
-2
6 additions, 2 deletions
logging/structure/structure.go
with
11 additions
and
8 deletions
logging/adapters/tendermint_log15/convert.go
+
5
−
6
View file @
8a1708f0
...
...
@@ -3,26 +3,25 @@ package adapters
import
(
"time"
"github.com/eris-ltd/eris-db/logging/loggers"
"github.com/eris-ltd/eris-db/logging/structure"
.
"github.com/eris-ltd/eris-db/util/slice"
"github.com/go-stack/stack"
"github.com/tendermint/log15"
"github.com/eris-ltd/eris-db/logging/structure"
"github.com/eris-ltd/eris-db/logging/loggers"
"fmt"
)
// Convert a go-kit log line (i.e. keyvals... interface{}) into a log15 record
// This allows us to use log15 output handlers
func
LogLineToRecord
(
keyvals
...
interface
{})
*
log15
.
Record
{
func
LogLineToRecord
(
keyvals
...
interface
{})
*
log15
.
Record
{
vals
,
ctx
:=
structure
.
ValuesAndContext
(
keyvals
,
structure
.
TimeKey
,
structure
.
MessageKey
,
structure
.
CallerKey
,
structure
.
LevelKey
)
// Mapping of log line to Record is on a best effort basis
theTime
,
_
:=
vals
[
structure
.
TimeKey
]
.
(
time
.
Time
)
call
,
_
:=
vals
[
structure
.
CallerKey
]
.
(
stack
.
Call
)
level
,
_
:=
vals
[
structure
.
LevelKey
]
.
(
string
)
message
,
_
:=
vals
[
structure
.
MessageKey
]
.
(
string
)
fmt
.
Println
(
keyvals
...
)
return
&
log15
.
Record
{
Time
:
theTime
,
Lvl
:
Log15LvlFromString
(
level
),
...
...
@@ -68,4 +67,4 @@ func Log15LvlFromString(level string) log15.Lvl {
}
return
log15
.
LvlDebug
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
logging/structure/structure.go
+
6
−
2
View file @
8a1708f0
...
...
@@ -9,15 +9,18 @@ const (
CallerKey
=
"caller"
// Key for String name for level
LevelKey
=
"level"
// Key to switch on for channel in a multiple channel logging context
ChannelKey
=
"channel"
//
S
tring message
key
//
Key for s
tring message
MessageKey
=
"message"
// Key for module or function or struct that is the subject of the logging
ComponentKey
=
"component"
)
// Pull the specified values from a structured log line into a map.
// Assumes keys are single-valued. And returns the rest as context.
// Assumes keys are single-valued.
// Returns a map of the key-values from the requested keys and
// the unmatched remainder keyvals as context as a slice of key-values.
func
ValuesAndContext
(
keyvals
[]
interface
{},
keys
...
interface
{})
(
map
[
interface
{}]
interface
{},
[]
interface
{})
{
vals
:=
make
(
map
[
interface
{}]
interface
{},
len
(
keys
))
...
...
@@ -30,6 +33,7 @@ func ValuesAndContext(keyvals []interface{},
for
i
:=
0
;
i
<
2
*
(
len
(
keyvals
)
/
2
);
i
+=
2
{
for
k
:=
0
;
k
<
len
(
keys
);
k
++
{
if
keyvals
[
i
]
==
keys
[
k
]
{
// Pull the matching key-value pair into vals to return
vals
[
keys
[
k
]]
=
keyvals
[
i
+
1
]
// Delete the key once it's found
keys
=
DeleteAt
(
keys
,
k
)
...
...
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