Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

improve logging, separate display/debug logs #423

Merged
merged 65 commits into from
Jan 1, 2018
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
94537d6
problem: glog to be able to handle display vs. debug logs
whilei Dec 6, 2017
9ac4f6a
problem: configure flags and default log settings
whilei Dec 6, 2017
02db146
problem: implement display logging cmd to log status, events
whilei Dec 6, 2017
0b16bcc
problem: update logging to better manage severity, verbosity, and use…
whilei Dec 6, 2017
c667f25
problem: chain identity parsed duplicitously
whilei Dec 6, 2017
ea18863
problem: bats tests failing
whilei Dec 6, 2017
f2cf2f2
fix: refactor chainIsMorden logic to check more readably
whilei Dec 6, 2017
2d5fe57
fix: edit log lines ref severity,verbosity
whilei Dec 6, 2017
b43f9b9
config: make default display verbosity=3
whilei Dec 6, 2017
5eccf16
problem: verbosityTraceFloor flag and API unnecessary
whilei Dec 7, 2017
a4d3ec2
problem: test logs expected states too verbosely
whilei Dec 7, 2017
9f31b40
problem: tests print logs to stderr which is loud
whilei Dec 7, 2017
c5e0f50
problem: glog_test lacks display tests
whilei Dec 7, 2017
bfd9ccc
fix: set glog quietness for tests (finish)
whilei Dec 7, 2017
cc8599f
problem: tests where os.Exit(1) called are skipped
whilei Dec 7, 2017
685a057
problem: windows path separator
whilei Dec 7, 2017
6d5588f
Fix TD display on blockchain.LoadLastState
whilei Dec 7, 2017
413fa9b
problem: makedag command appears silent
whilei Dec 8, 2017
bb85085
add notice that it may take a while to export bc
whilei Dec 12, 2017
d1d37df
the one where I install the progress bar for exporting
whilei Dec 12, 2017
557ac5a
Merge master and fix conflicts
whilei Dec 12, 2017
a227cca
problem: default glog vars and refactor setup logs from main
whilei Dec 12, 2017
ec3ee67
fix: remove 'WARNING' prefix from severity=warn log lines
whilei Dec 12, 2017
a639c65
fix: refactor status log cmd
whilei Dec 12, 2017
8fcf18d
fix: refactor log config setup to file
whilei Dec 12, 2017
d978fda
problem: refactor m/log config and logging
whilei Dec 12, 2017
738df1c
Revert "the one where I install the progress bar for exporting"
whilei Dec 12, 2017
d0bfd81
fix: use FormatUint instead of Itoa
whilei Dec 14, 2017
bf0ccd9
problem: logging output doesn't match initial spec
whilei Dec 14, 2017
7532f0a
problem: log display is inflexible and very hard coded
whilei Dec 15, 2017
298b168
problem: log display fmt is hardcoded
whilei Dec 15, 2017
f6f1a7d
solution: add comments
whilei Dec 15, 2017
1255a19
problem: log logic is clumped awkwardly
whilei Dec 15, 2017
b2c60ee
problem: log events should not be hardcoded strings
whilei Dec 15, 2017
3950b33
problem: `~` not expanded in `--log-dir`
tzdybal Dec 18, 2017
c0a7630
experimental: implement dash display fmt
whilei Dec 16, 2017
a4cfc07
problem: date format for display log not to spec
whilei Dec 18, 2017
cd58c29
solution: set default log-status =60s per spec
whilei Dec 18, 2017
1c04a3b
problem: improve disabling and default for log status interval
whilei Dec 18, 2017
b0fed84
solution: move experiment logging flag to ex. section of help
whilei Dec 18, 2017
59e079d
Merge master and fix conflicts
whilei Dec 18, 2017
fb9dc2e
solution: fix debuglog formatting color
whilei Dec 18, 2017
1e479fd
solution: use stringer for diplay mode
whilei Dec 18, 2017
b95b80a
solution: improve log line mode decision for _basic
whilei Dec 18, 2017
b0bfb55
solution: refactor dispatcher for readability and no races
whilei Dec 18, 2017
298ab62
problem: display severity trace thresh is sev=fatal
whilei Dec 18, 2017
4fdb9de
problem: update glog tests for new format spec
whilei Dec 18, 2017
159f9f5
solution: improve status log condit
whilei Dec 18, 2017
6e9fbfb
solution: address pr feedback fromr @tzdybal
whilei Dec 19, 2017
1abeb28
(nonfunctional): update comment with fuller example of dash
whilei Dec 19, 2017
6b31365
problem: no logging for mined block event
whilei Dec 19, 2017
c55bc8a
solution: refactor display basic logs
whilei Dec 19, 2017
1fe563a
Merge branch 'master' into feat/log-display
whilei Dec 19, 2017
ee7f170
problem: import mode is weird to happen before sync
whilei Dec 19, 2017
87aaf61
Restart CI
whilei Dec 19, 2017
fcbc260
Restart CI
whilei Dec 20, 2017
060580d
problem: geth killing information not visible
tzdybal Dec 21, 2017
b6e0cc7
Restart CI
whilei Dec 27, 2017
d860e63
Merge branch 'master' into feat/log-display
whilei Dec 28, 2017
1fd96c0
problem: import logline shows db latest head instead of event block
whilei Dec 30, 2017
3b4f068
problem: should show +n blocks imported when n>1
whilei Dec 30, 2017
b46f10a
problem: should show shutdown sig received
whilei Dec 30, 2017
0e48418
solution: txs/mgas should sum over last n imported blocks
whilei Dec 30, 2017
1248ca4
problem: spacing on chain insert delta
whilei Dec 30, 2017
8acd46a
Merge branch 'master' into feat/log-display
whilei Jan 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions accounts/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package accounts
import (
"fmt"
"github.com/davecgh/go-spew/spew"
"github.com/ethereumproject/go-ethereum/logger/glog"
"io/ioutil"
"math/rand"
"os"
Expand All @@ -29,6 +30,11 @@ import (
"time"
)

func init() {
glog.SetD(0)
glog.SetV(0)
}

var testSigData = make([]byte, 32)

func tmpManager(t *testing.T) (string, *Manager) {
Expand Down
2 changes: 1 addition & 1 deletion accounts/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (w *watcher) loop() {

err := notify.Watch(w.ac.getKeydir(), w.ev, notify.All)
if err != nil {
glog.V(logger.Detail).Infof("can't watch %s: %v", w.ac.getKeydir(), err)
glog.V(logger.Warn).Errorf("can't watch %s: %v", w.ac.getKeydir(), err)
return
}
defer notify.Stop(w.ev)
Expand Down
4 changes: 3 additions & 1 deletion cmd/geth/accountcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func accountIndex(ctx *cli.Context) error {
if len(errs) > 0 {
for _, e := range errs {
if e != nil {
glog.V(logger.Error).Infof("init cache db err: %v", e)
glog.V(logger.Error).Errorf("init cache db err: %v", e)
}
}
}
Expand Down Expand Up @@ -236,10 +236,12 @@ func unlockAccount(ctx *cli.Context, accman *accounts.Manager, address string, i
err = accman.Unlock(account, password)
if err == nil {
glog.V(logger.Info).Infof("Unlocked account %x", account.Address)
glog.D(logger.Error).Infof("Unlocked account %x", account.Address)
return account, password
}
if err, ok := err.(*accounts.AmbiguousAddrError); ok {
glog.V(logger.Info).Infof("Unlocked account %x", account.Address)
glog.D(logger.Error).Infof("Unlocked account %x", account.Address)
return ambiguousAddrRecovery(accman, err, password), password
}
if err != accounts.ErrDecrypt {
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/chainconfig.bats
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ teardown() {
run $GETH_CMD --data-dir $DATA_DIR --chain kitty --bootnodes=enode://e809c4a2fec7daed400e5e28564e23693b23b2cc5a019b612505631bbe7b9ccf709c1796d2a3d29ef2b045f210caf51e3c4f5b6d3587d43ad5d6397526fa6179@174.112.32.157:30303 console
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" == *"WARNING"* ]]
[[ "$output" == *"Overwriting external bootnodes"* ]]
}

# Test fails to load invalid chain configuration from testdata/ JSON file.
Expand Down
66 changes: 39 additions & 27 deletions cmd/geth/cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ teardown() {
echo "$output"

[ "$status" -eq 0 ]
[[ "$output" == *"Starting"* ]]
[[ "$output" == *"Blockchain DB Version: "* ]]
[[ "$output" == *"Starting Server"* ]]
[[ "$output" == *"Blockchain"* ]]
[[ "$output" == *"Local head"* ]]
[[ "$output" == *"Starting server"* ]]
}

@test "displays help with invalid flag and valid command" {
Expand Down Expand Up @@ -75,7 +75,7 @@ teardown() {
@test "custom testnet subdir --testnet --chain=morden2 | exit !=0" {
run $GETH_CMD --data-dir $DATA_DIR --testnet --chain=morden2 --maxpeers 0 --nodiscover --nat none --ipcdisable --exec 'exit' console
echo "$output"
[ "$status" -ne 0 ]
[ "$status" -ne 0 ]
[[ "$output" == *"invalid flag "* ]]
}

Expand Down Expand Up @@ -109,57 +109,67 @@ teardown() {
# # ipc-path/ipcpath
run $GETH_CMD --data-dir $DATA_DIR --ipc-path abc.ipc console
[ "$status" -eq 0 ]
[[ "$output" == *"IPC endpoint opened: $DATA_DIR/mainnet/abc.ipc"* ]]
echo "$output"
[[ "$output" == *"IPC endpoint opened"* ]]
[[ "$output" == *"$DATA_DIR/mainnet/abc.ipc"* ]]

run $GETH_CMD --data-dir $DATA_DIR --ipcpath $DATA_DIR/mainnet/abc.ipc console
[ "$status" -eq 0 ]
[[ "$output" == *"IPC endpoint opened: $DATA_DIR/mainnet/abc.ipc"* ]]
echo "$output"
[[ "$output" == *"IPC endpoint opened"* ]]
[[ "$output" == *"$DATA_DIR/mainnet/abc.ipc"* ]]

run $GETH_CMD --data-dir $DATA_DIR --ipc-path $DATA_DIR/mainnet/abc console
[ "$status" -eq 0 ]
[[ "$output" == *"IPC endpoint opened: $DATA_DIR/mainnet/abc"* ]]
echo "$output"
[[ "$output" == *"IPC endpoint opened"* ]]
[[ "$output" == *"$DATA_DIR/mainnet/abc"* ]]

run $GETH_CMD --data-dir $DATA_DIR --ipcpath $DATA_DIR/mainnet/abc console
[ "$status" -eq 0 ]
[[ "$output" == *"IPC endpoint opened: $DATA_DIR/mainnet/abc"* ]]

echo "$output"
[[ "$output" == *"IPC endpoint opened"* ]]
[[ "$output" == *"$DATA_DIR/mainnet/abc"* ]]

}

# ... assuming that if two work, the rest will work.
@test "aliasing hyphenated flags: --no-discover==--nodiscover, --ipc-disable==--ipcdisable | exit 0" {
old_command_names=(nodiscover ipcdisable)
old_command_names=(nodiscover ipcdisable)
new_command_names=(no-discover ipc-disable)

for var in "${old_command_names[@]}"
do
# hardcode --datadir/--data-dir
run $GETH_CMD --datadir $DATA_DIR --$var --exec 'exit' console
[ "$status" -eq 0 ]
[[ "$output" == *"Starting"* ]]
[[ "$output" == *"Blockchain DB Version: "* ]]
[[ "$output" == *"Starting Server"* ]]
[[ "$output" == *"Blockchain"* ]]
[[ "$output" == *"Local head"* ]]
[[ "$output" == *"Starting server"* ]]
done

for var in "${new_command_names[@]}"
do
run $GETH_CMD --data-dir $DATA_DIR --$var --exec 'exit' console
[ "$status" -eq 0 ]
[[ "$output" == *"Starting"* ]]
[[ "$output" == *"Blockchain DB Version: "* ]]
[[ "$output" == *"Starting Server"* ]]
[[ "$output" == *"Blockchain"* ]]
[[ "$output" == *"Local head"* ]]
[[ "$output" == *"Starting server"* ]]
done
}

@test "--cache 16 | exit 0" {
run $GETH_CMD --data-dir $DATA_DIR --cache 17 console
[ "$status" -eq 0 ]
[[ "$output" == *"Allotted 17MB cache"* ]]
[[ "$output" == *"Allotted"* ]]
[[ "$output" == *"17MB"* ]]
[[ "$output" == *"cache"* ]]
}

# Test `dump` command.
# All tests copy testdata/testdatadir to $DATA_DIR to ensure we're consistently testing against a not-only-init'ed chaindb.
@test "dump [noargs] | exit >0" {
cp -a $BATS_TEST_DIRNAME/../../cmd/geth/testdata/testdatadir/. $DATA_DIR/
cp -a $BATS_TEST_DIRNAME/../../cmd/geth/testdata/testdatadir/. $DATA_DIR/
run $GETH_CMD --data-dir $DATA_DIR dump
echo "$output"
[ "$status" -gt 0 ]
Expand All @@ -174,8 +184,8 @@ teardown() {
[[ "$output" == *"balance"* ]]
[[ "$output" == *"accounts"* ]]
[[ "$output" == *"d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"* ]] # block state root
[[ "$output" == *"ffec0913c635baca2f5e57a37aa9fb7b6c9b6e26"* ]] # random hex address existing in genesis
[[ "$output" == *"253319000000000000000"* ]] # random address balance existing in genesis
[[ "$output" == *"ffec0913c635baca2f5e57a37aa9fb7b6c9b6e26"* ]] # random hex address existing in genesis
[[ "$output" == *"253319000000000000000"* ]] # random address balance existing in genesis
}
@test "dump 0 fff7ac99c8e4feb60c9750054bdc14ce1857f181 | exit 0" {
cp -a $BATS_TEST_DIRNAME/../../cmd/geth/testdata/testdatadir/. $DATA_DIR/
Expand All @@ -198,7 +208,7 @@ teardown() {
[[ "$output" == *"balance"* ]]
[[ "$output" == *"accounts"* ]]
[[ "$output" == *"d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"* ]] # block 0 state root

[[ "$output" == *"fff7ac99c8e4feb60c9750054bdc14ce1857f181"* ]] # hex address
[[ "$output" == *"1000000000000000000000"* ]] # address balance

Expand All @@ -214,10 +224,10 @@ teardown() {
[[ "$output" == *"root"* ]] # block state root
[[ "$output" == *"balance"* ]]
[[ "$output" == *"accounts"* ]]

[[ "$output" == *"d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"* ]] # block 0 state root
[[ "$output" == *"d67e4d450343046425ae4271474353857ab860dbc0a1dde64b41b5cd3a532bf3"* ]] # block 1 state root

[[ "$output" == *"fff7ac99c8e4feb60c9750054bdc14ce1857f181"* ]] # hex address
[[ "$output" == *"1000000000000000000000"* ]] # address balance

Expand All @@ -232,9 +242,9 @@ teardown() {
[[ "$output" == *"root"* ]] # block state root
[[ "$output" == *"balance"* ]]
[[ "$output" == *"accounts"* ]]

[[ "$output" == *"d7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544"* ]] # block 0 state root

[[ "$output" == *"fff7ac99c8e4feb60c9750054bdc14ce1857f181"* ]] # hex address
[[ "$output" == *"1000000000000000000000"* ]] # address balance

Expand Down Expand Up @@ -277,6 +287,7 @@ teardown() {
# When I tried using heredoc and other more elegant solutions than line-by-line checking.

# Chain Configuration Genesis
echo "$output"
[[ "$output" == *"mainnet"* ]]
[[ "$output" == *"Ethereum Classic Mainnet"* ]]
[[ "$output" == *"Genesis"* ]]
Expand All @@ -293,6 +304,7 @@ teardown() {
[ "$status" -eq 0 ]

# Chain database Genesis
echo "$output"
[[ "$output" == *"Genesis"* ]]
[[ "$output" == *"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"* ]]
[[ "$output" == *"0x0000000000000000000000000000000000000000000000000000000000000000"* ]]
Expand Down Expand Up @@ -337,4 +349,4 @@ teardown() {
[[ "$output" == *"3141592"* ]]
[[ "$output" == *"0"* ]]
[[ "$output" == *"[]"* ]]
}
}
2 changes: 1 addition & 1 deletion cmd/geth/cmd.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ teardown() {
run $GETH_CMD --data-dir $DATA_DIR reset <<< $'y'
[ "$status" -eq 0 ]
! [ -d $DATA_DIR/mainnet/chaindata ]
}
}
Loading