good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
open
bor
Commits
e02883c0
Unverified
Commit
e02883c0
authored
Feb 28, 2017
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
core, log: track field length and pad to align
parent
e588e0ca
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
core/blockchain.go
+5
-5
5 additions, 5 deletions
core/blockchain.go
core/headerchain.go
+2
-2
2 additions, 2 deletions
core/headerchain.go
log/format.go
+25
-3
25 additions, 3 deletions
log/format.go
with
32 additions
and
10 deletions
core/blockchain.go
+
5
−
5
View file @
e02883c0
...
...
@@ -798,8 +798,8 @@ func (self *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain
// Report some public statistics so the user has a clue what's going on
last
:=
blockChain
[
len
(
blockChain
)
-
1
]
log
.
Info
(
"Imported new block receipts"
,
"count"
,
stats
.
processed
,
"
number"
,
last
.
Number
(),
"hash"
,
last
.
Hash
(
),
"
elapsed"
,
common
.
PrettyDuration
(
time
.
Since
(
start
)
),
"ignored"
,
stats
.
ignored
)
log
.
Info
(
"Imported new block receipts"
,
"count"
,
stats
.
processed
,
"
elapsed"
,
common
.
PrettyDuration
(
time
.
Since
(
start
)
),
"
number"
,
last
.
Number
(),
"hash"
,
last
.
Hash
(
),
"ignored"
,
stats
.
ignored
)
return
0
,
nil
}
...
...
@@ -1054,9 +1054,9 @@ func (st *insertStats) report(chain []*types.Block, index int) {
txs
=
countTransactions
(
chain
[
st
.
lastIndex
:
index
+
1
])
)
context
:=
[]
interface
{}{
"blocks"
,
st
.
processed
,
"
number"
,
end
.
Number
()
,
"
h
as
h
"
,
end
.
Hash
(),
"txs"
,
txs
,
"mgas"
,
float64
(
st
.
usedGas
)
/
1000
00
0
,
"elapsed"
,
common
.
PrettyDuration
(
elapsed
),
"
mgasps"
,
float64
(
st
.
usedGas
)
*
1000
/
float64
(
elapsed
),
"blocks"
,
st
.
processed
,
"
txs"
,
txs
,
"
mg
as"
,
float64
(
st
.
usedGas
)
/
1000000
,
"elapsed"
,
common
.
PrettyDuration
(
elapsed
),
"mgas
ps
"
,
float64
(
st
.
usedGas
)
*
1000
/
float64
(
elapsed
),
"
number"
,
end
.
Number
(),
"hash"
,
end
.
Hash
(
),
}
if
st
.
queued
>
0
{
context
=
append
(
context
,
[]
interface
{}{
"queued"
,
st
.
queued
}
...
)
...
...
This diff is collapsed.
Click to expand it.
core/headerchain.go
+
2
−
2
View file @
e02883c0
...
...
@@ -330,8 +330,8 @@ func (hc *HeaderChain) InsertHeaderChain(chain []*types.Header, checkFreq int, w
}
// Report some public statistics so the user has a clue what's going on
last
:=
chain
[
len
(
chain
)
-
1
]
log
.
Info
(
"Imported new block headers"
,
"count"
,
stats
.
processed
,
"
number"
,
last
.
Number
,
"hash"
,
last
.
Hash
(
),
"
elapsed"
,
common
.
PrettyDuration
(
time
.
Since
(
start
)
),
"ignored"
,
stats
.
ignored
)
log
.
Info
(
"Imported new block headers"
,
"count"
,
stats
.
processed
,
"
elapsed"
,
common
.
PrettyDuration
(
time
.
Since
(
start
)
),
"
number"
,
last
.
Number
,
"hash"
,
last
.
Hash
(
),
"ignored"
,
stats
.
ignored
)
return
0
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
log/format.go
+
25
−
3
View file @
e02883c0
...
...
@@ -10,6 +10,7 @@ import (
"sync"
"sync/atomic"
"time"
"unicode/utf8"
)
const
(
...
...
@@ -43,6 +44,13 @@ var locationEnabled uint32
// padded to to aid in alignment.
var
locationLength
uint32
// fieldPadding is a global map with maximum field value lengths seen until now
// to allow padding log contexts in a bit smarter way.
var
fieldPadding
=
make
(
map
[
string
]
int
)
// fieldPaddingLock is a global mutex protecting the field padding map.
var
fieldPaddingLock
sync
.
RWMutex
type
Format
interface
{
Format
(
r
*
Record
)
[]
byte
}
...
...
@@ -163,15 +171,29 @@ func logfmt(buf *bytes.Buffer, ctx []interface{}, color int, term bool) {
}
// XXX: we should probably check that all of your key bytes aren't invalid
fieldPaddingLock
.
RLock
()
padding
:=
fieldPadding
[
k
]
fieldPaddingLock
.
RUnlock
()
length
:=
utf8
.
RuneCountInString
(
v
)
if
padding
<
length
{
padding
=
length
fieldPaddingLock
.
Lock
()
fieldPadding
[
k
]
=
padding
fieldPaddingLock
.
Unlock
()
}
if
color
>
0
{
fmt
.
Fprintf
(
buf
,
"
\x1b
[%dm%s
\x1b
[0m=
%s
"
,
color
,
k
,
v
)
fmt
.
Fprintf
(
buf
,
"
\x1b
[%dm%s
\x1b
[0m="
,
color
,
k
)
}
else
{
buf
.
WriteString
(
k
)
buf
.
WriteByte
(
'='
)
}
buf
.
WriteString
(
v
)
if
i
<
len
(
ctx
)
-
2
{
buf
.
Write
(
bytes
.
Repeat
([]
byte
{
' '
},
padding
-
length
))
}
}
buf
.
WriteByte
(
'\n'
)
}
...
...
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