From d6ea5008a25966a51622bf1588640b169cb49254 Mon Sep 17 00:00:00 2001 From: Alan Chen Date: Tue, 12 Sep 2017 15:25:18 +0800 Subject: [PATCH] charts, client, common, container, genesis, k8s, log: logger refactoing for correct caller line number --- charts/genesis.go | 1 - charts/log.go | 23 +++++++++++++++++++++++ charts/static_nodes.go | 1 - client/client_test.go | 2 -- client/log.go | 23 +++++++++++++++++++++++ common/log.go | 23 +++++++++++++++++++++++ common/utils.go | 2 -- container/blockchain.go | 1 - container/constellation.go | 1 - container/container.go | 2 -- container/ethereum.go | 1 - container/log.go | 23 +++++++++++++++++++++++ container/network.go | 2 -- genesis/genesis.go | 1 - genesis/log.go | 23 +++++++++++++++++++++++ genesis/options.go | 1 - k8s/blockchain.go | 1 - k8s/blockchain_example.go | 2 -- k8s/ethereum_example.go | 1 - k8s/log.go | 23 +++++++++++++++++++++++ k8s/utils.go | 2 -- log/log.go | 20 -------------------- 22 files changed, 138 insertions(+), 41 deletions(-) create mode 100644 charts/log.go create mode 100644 client/log.go create mode 100644 common/log.go create mode 100644 container/log.go create mode 100644 genesis/log.go create mode 100644 k8s/log.go diff --git a/charts/genesis.go b/charts/genesis.go index 96881423..b9dbd947 100644 --- a/charts/genesis.go +++ b/charts/genesis.go @@ -25,7 +25,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/getamis/istanbul-tools/genesis" - "github.com/getamis/istanbul-tools/log" ) type GenesisChart struct { diff --git a/charts/log.go b/charts/log.go new file mode 100644 index 00000000..cd207f15 --- /dev/null +++ b/charts/log.go @@ -0,0 +1,23 @@ +// Copyright 2017 AMIS Technologies +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package charts + +import ( + logging "github.com/getamis/istanbul-tools/log" +) + +var log = logging.New() diff --git a/charts/static_nodes.go b/charts/static_nodes.go index 81f870be..6023cb57 100644 --- a/charts/static_nodes.go +++ b/charts/static_nodes.go @@ -23,7 +23,6 @@ import ( "strings" "github.com/getamis/istanbul-tools/common" - "github.com/getamis/istanbul-tools/log" ) type StaticNodesChart struct { diff --git a/client/client_test.go b/client/client_test.go index 10124027..d9245700 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -20,8 +20,6 @@ import ( "context" "github.com/ethereum/go-ethereum/common" - - "github.com/getamis/istanbul-tools/log" ) func ExampleStartMining() { diff --git a/client/log.go b/client/log.go new file mode 100644 index 00000000..fd6382e7 --- /dev/null +++ b/client/log.go @@ -0,0 +1,23 @@ +// Copyright 2017 AMIS Technologies +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package client + +import ( + logging "github.com/getamis/istanbul-tools/log" +) + +var log = logging.New() diff --git a/common/log.go b/common/log.go new file mode 100644 index 00000000..73a5ca94 --- /dev/null +++ b/common/log.go @@ -0,0 +1,23 @@ +// Copyright 2017 AMIS Technologies +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package common + +import ( + logging "github.com/getamis/istanbul-tools/log" +) + +var log = logging.New() diff --git a/common/utils.go b/common/utils.go index c4da3c82..24f4e928 100644 --- a/common/utils.go +++ b/common/utils.go @@ -31,8 +31,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/p2p/discover" uuid "github.com/satori/go.uuid" - - "github.com/getamis/istanbul-tools/log" ) const ( diff --git a/container/blockchain.go b/container/blockchain.go index 40c8bc99..434a4a91 100644 --- a/container/blockchain.go +++ b/container/blockchain.go @@ -35,7 +35,6 @@ import ( istcommon "github.com/getamis/istanbul-tools/common" "github.com/getamis/istanbul-tools/genesis" - "github.com/getamis/istanbul-tools/log" ) const ( diff --git a/container/constellation.go b/container/constellation.go index 0f843ea6..1ffe8b7c 100644 --- a/container/constellation.go +++ b/container/constellation.go @@ -34,7 +34,6 @@ import ( "github.com/docker/go-connections/nat" "github.com/getamis/istanbul-tools/common" - "github.com/getamis/istanbul-tools/log" ) //TODO: refactor this with ethereum options? diff --git a/container/container.go b/container/container.go index bb8dedcd..3fcce4aa 100644 --- a/container/container.go +++ b/container/container.go @@ -22,8 +22,6 @@ import ( "os" "github.com/docker/docker/client" - - "github.com/getamis/istanbul-tools/log" ) func (eth *ethereum) Image() string { diff --git a/container/ethereum.go b/container/ethereum.go index f231f542..6913e3ec 100644 --- a/container/ethereum.go +++ b/container/ethereum.go @@ -45,7 +45,6 @@ import ( "github.com/getamis/istanbul-tools/client" istcommon "github.com/getamis/istanbul-tools/common" "github.com/getamis/istanbul-tools/genesis" - "github.com/getamis/istanbul-tools/log" ) const ( diff --git a/container/log.go b/container/log.go new file mode 100644 index 00000000..1af7511e --- /dev/null +++ b/container/log.go @@ -0,0 +1,23 @@ +// Copyright 2017 AMIS Technologies +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package container + +import ( + logging "github.com/getamis/istanbul-tools/log" +) + +var log = logging.New() diff --git a/container/network.go b/container/network.go index 3543368d..65f39acc 100644 --- a/container/network.go +++ b/container/network.go @@ -26,8 +26,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" "github.com/docker/docker/client" - - "github.com/getamis/istanbul-tools/log" ) const ( diff --git a/genesis/genesis.go b/genesis/genesis.go index 36ed06f1..0aba7135 100644 --- a/genesis/genesis.go +++ b/genesis/genesis.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/getamis/istanbul-tools/common" - "github.com/getamis/istanbul-tools/log" ) const ( diff --git a/genesis/log.go b/genesis/log.go new file mode 100644 index 00000000..a064bb69 --- /dev/null +++ b/genesis/log.go @@ -0,0 +1,23 @@ +// Copyright 2017 AMIS Technologies +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package genesis + +import ( + logging "github.com/getamis/istanbul-tools/log" +) + +var log = logging.New() diff --git a/genesis/options.go b/genesis/options.go index 1d3b44b2..561e42e9 100644 --- a/genesis/options.go +++ b/genesis/options.go @@ -24,7 +24,6 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/getamis/istanbul-tools/cmd/istanbul/extra" - "github.com/getamis/istanbul-tools/log" ) type Option func(*core.Genesis) diff --git a/k8s/blockchain.go b/k8s/blockchain.go index 5b55552a..b692d562 100644 --- a/k8s/blockchain.go +++ b/k8s/blockchain.go @@ -24,7 +24,6 @@ import ( "github.com/getamis/istanbul-tools/charts" istcommon "github.com/getamis/istanbul-tools/common" "github.com/getamis/istanbul-tools/container" - "github.com/getamis/istanbul-tools/log" ) func NewBlockchain(numOfValidators int, gaslimit uint64, options ...Option) (bc *blockchain) { diff --git a/k8s/blockchain_example.go b/k8s/blockchain_example.go index fe9d00a0..2ca175c1 100644 --- a/k8s/blockchain_example.go +++ b/k8s/blockchain_example.go @@ -18,8 +18,6 @@ package k8s import ( "time" - - "github.com/getamis/istanbul-tools/log" ) func ExampleK8SBlockchain() { diff --git a/k8s/ethereum_example.go b/k8s/ethereum_example.go index c585bdcd..74bc73a8 100644 --- a/k8s/ethereum_example.go +++ b/k8s/ethereum_example.go @@ -20,7 +20,6 @@ import ( "github.com/getamis/istanbul-tools/charts" "github.com/getamis/istanbul-tools/common" "github.com/getamis/istanbul-tools/genesis" - "github.com/getamis/istanbul-tools/log" ) func ExampleK8SEthereum() { diff --git a/k8s/log.go b/k8s/log.go new file mode 100644 index 00000000..93d91291 --- /dev/null +++ b/k8s/log.go @@ -0,0 +1,23 @@ +// Copyright 2017 AMIS Technologies +// This file is part of the go-ethereum library. +// +// The go-ethereum library is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// The go-ethereum library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the go-ethereum library. If not, see . + +package k8s + +import ( + logging "github.com/getamis/istanbul-tools/log" +) + +var log = logging.New() diff --git a/k8s/utils.go b/k8s/utils.go index 05937e16..0b94d739 100644 --- a/k8s/utils.go +++ b/k8s/utils.go @@ -25,8 +25,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" - - "github.com/getamis/istanbul-tools/log" ) const ( diff --git a/log/log.go b/log/log.go index 0b61e2cb..887c5646 100644 --- a/log/log.go +++ b/log/log.go @@ -37,23 +37,3 @@ func init() { func New(ctx ...interface{}) log15.Logger { return defaultLogger.New(ctx...) } - -func Info(msg string, ctx ...interface{}) { - defaultLogger.Info(msg, ctx...) -} - -func Debug(msg string, ctx ...interface{}) { - defaultLogger.Debug(msg, ctx...) -} - -func Warn(msg string, ctx ...interface{}) { - defaultLogger.Warn(msg, ctx) -} - -func Error(msg string, ctx ...interface{}) { - defaultLogger.Error(msg, ctx...) -} - -func Fatal(msg string, ctx ...interface{}) { - defaultLogger.Crit(msg, ctx...) -}