Skip to content

Commit a7ad9c3

Browse files
committed
Merge branch 'develop' into conversion
2 parents ce862ee + 38c7c58 commit a7ad9c3

6 files changed

Lines changed: 32 additions & 7 deletions

File tree

‎cmd/ethereum/main.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func accountList(ctx *cli.Context) {
251251
utils.Fatalf("Could not list accounts: %v", err)
252252
}
253253
for _, acct := range accts {
254-
fmt.Printf("Address: %#x\n", acct)
254+
fmt.Printf("Address: %x\n", acct)
255255
}
256256
}
257257

@@ -278,7 +278,7 @@ func accountCreate(ctx *cli.Context) {
278278
if err != nil {
279279
utils.Fatalf("Could not create the account: %v", err)
280280
}
281-
fmt.Printf("Address: %#x\n", acct.Address)
281+
fmt.Printf("Address: %x\n", acct.Address)
282282
}
283283

284284
func importchain(ctx *cli.Context) {

‎logger/log.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func New(datadir string, logFile string, logLevel int, logFormat string) LogSyst
3030
switch logFormat {
3131
case "raw":
3232
sys = NewRawLogSystem(writer, 0, LogLevel(logLevel))
33+
case "json":
34+
sys = NewJsonLogSystem(writer, 0, LogLevel(logLevel))
3335
default:
3436
sys = NewStdLogSystem(writer, log.LstdFlags, LogLevel(logLevel))
3537
}

‎logger/logsystem.go‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,27 @@ func (t *rawLogSystem) SetLogLevel(i LogLevel) {
6161
func (t *rawLogSystem) GetLogLevel() LogLevel {
6262
return LogLevel(atomic.LoadUint32(&t.level))
6363
}
64+
65+
// NewRawLogSystem creates a LogSystem that prints to the given writer without
66+
// adding extra information. Suitable for preformatted output
67+
func NewJsonLogSystem(writer io.Writer, flags int, level LogLevel) LogSystem {
68+
logger := log.New(writer, "", 0)
69+
return &jsonLogSystem{logger, uint32(level)}
70+
}
71+
72+
type jsonLogSystem struct {
73+
logger *log.Logger
74+
level uint32
75+
}
76+
77+
func (t *jsonLogSystem) LogPrint(level LogLevel, msg string) {
78+
t.logger.Print(msg)
79+
}
80+
81+
func (t *jsonLogSystem) SetLogLevel(i LogLevel) {
82+
atomic.StoreUint32(&t.level, uint32(i))
83+
}
84+
85+
func (t *jsonLogSystem) GetLogLevel() LogLevel {
86+
return LogLevel(atomic.LoadUint32(&t.level))
87+
}

‎logger/sys.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ func dispatchLoop() {
7676
func sysLoop(sys LogSystem, in <-chan message, wg *sync.WaitGroup) {
7777
for msg := range in {
7878
switch sys.(type) {
79-
case *rawLogSystem:
80-
// This is a semantic hack since rawLogSystem has little to do with JsonLevel
79+
case *jsonLogSystem:
8180
if msg.level == JsonLevel {
8281
sys.LogPrint(msg.level, msg.msg)
8382
}

‎p2p/discover/node.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ type NodeID [nodeIDBits / 8]byte
143143

144144
// NodeID prints as a long hexadecimal number.
145145
func (n NodeID) String() string {
146-
return fmt.Sprintf("%#x", n[:])
146+
return fmt.Sprintf("%x", n[:])
147147
}
148148

149149
// The Go syntax representation of a NodeID is a call to HexID.
150150
func (n NodeID) GoString() string {
151-
return fmt.Sprintf("discover.HexID(\"%#x\")", n[:])
151+
return fmt.Sprintf("discover.HexID(\"%x\")", n[:])
152152
}
153153

154154
// HexID converts a hex string to a NodeID.

‎p2p/message.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type Msg struct {
3333
// For the decoding rules, please see package rlp.
3434
func (msg Msg) Decode(val interface{}) error {
3535
if err := rlp.Decode(msg.Payload, val); err != nil {
36-
return newPeerError(errInvalidMsg, "(code %#x) (size %d) %v", msg.Code, msg.Size, err)
36+
return newPeerError(errInvalidMsg, "(code %x) (size %d) %v", msg.Code, msg.Size, err)
3737
}
3838
return nil
3939
}

0 commit comments

Comments
 (0)