Skip to content

Commit 8b4a70a

Browse files
committed
Format logging messages
find . -name '*.go' ! -path './vendor/*' ! -path './test/GNTE/*' -exec sed -i \ 's/\.\(Debug\|Info\|Warn\|Warning\|Error\|Fatal\|Panicf\?\)("\([[:upper:]]\)\([[:lower:]]\+[^[:alnum:]]\)/.\1("\L\2\3/' {} +
1 parent d9a472e commit 8b4a70a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+468
-468
lines changed

blockproducer/chain.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
187187
"irre_count": irre.count,
188188
"head_hash": v.hash.Short(4),
189189
"head_count": v.count,
190-
}).Debug("Checking head")
190+
}).Debug("checking head")
191191
if v.hasAncestor(irre) {
192192
if br, ierr = fork(irre, v, immutable, txPool); ierr != nil {
193193
err = errors.Wrapf(ierr, "failed to rebuild branch with head %s", v.hash.Short(4))
@@ -341,7 +341,7 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
341341
"block_time": b.Timestamp(),
342342
"block_hash": b.BlockHash().Short(4),
343343
"parent_hash": b.ParentHash().Short(4),
344-
}).WithError(err).Debug("Broadcasting new block to other peers")
344+
}).WithError(err).Debug("broadcasting new block to other peers")
345345
}, c.period)
346346
}(s)
347347
}
@@ -436,7 +436,7 @@ func (c *Chain) syncHeads() {
436436
log.WithFields(log.Fields{
437437
"next_height": c.getNextHeight(),
438438
"height": h,
439-
}).Debug("Synchronizing head blocks")
439+
}).Debug("synchronizing head blocks")
440440
c.syncCurrentHead(c.ctx)
441441
}
442442
c.increaseNextHeight()
@@ -502,7 +502,7 @@ func (c *Chain) addTx(tx pi.Transaction) {
502502
"remote": id,
503503
"tx_hash": tx.Hash().Short(4),
504504
"tx_type": tx.GetTransactionType(),
505-
}).WithError(err).Debug("Broadcasting transaction to other peers")
505+
}).WithError(err).Debug("broadcasting transaction to other peers")
506506
}, c.period)
507507
}(v)
508508
}
@@ -511,17 +511,17 @@ func (c *Chain) addTx(tx pi.Transaction) {
511511
select {
512512
case c.pendingTxs <- tx:
513513
case <-c.ctx.Done():
514-
log.WithError(c.ctx.Err()).Error("Add transaction aborted")
514+
log.WithError(c.ctx.Err()).Error("add transaction aborted")
515515
}
516516
}
517517

518518
func (c *Chain) processTx(tx pi.Transaction) {
519519
if err := tx.Verify(); err != nil {
520-
log.WithError(err).Error("Failed to verify transaction")
520+
log.WithError(err).Error("failed to verify transaction")
521521
return
522522
}
523523
if err := c.storeTx(tx); err != nil {
524-
log.WithError(err).Error("Failed to add transaction")
524+
log.WithError(err).Error("failed to add transaction")
525525
}
526526
}
527527

@@ -540,7 +540,7 @@ func (c *Chain) mainCycle(ctx context.Context) {
540540
for {
541541
select {
542542
case <-ctx.Done():
543-
log.WithError(ctx.Err()).Debug("Abort main cycle")
543+
log.WithError(ctx.Err()).Debug("abort main cycle")
544544
return
545545
default:
546546
c.syncCurrentHead(ctx) // Try to fetch block at height `nextHeight-1`
@@ -553,7 +553,7 @@ func (c *Chain) mainCycle(ctx context.Context) {
553553
"head_block": c.head().hash.Short(4),
554554
"now_time": t.Format(time.RFC3339Nano),
555555
"duration": d,
556-
}).Debug("Main cycle")
556+
}).Debug("main cycle")
557557
time.Sleep(d)
558558
} else {
559559
// Try to produce block at `nextHeight` if it's my turn, and increase height by 1
@@ -603,7 +603,7 @@ func (c *Chain) syncCurrentHead(ctx context.Context) {
603603
"local": c.peerInfo(),
604604
"remote": id,
605605
"height": h,
606-
}).WithError(err).Warn("Failed to fetch block")
606+
}).WithError(err).Warn("failed to fetch block")
607607
return
608608
}
609609
log.WithFields(log.Fields{
@@ -612,11 +612,11 @@ func (c *Chain) syncCurrentHead(ctx context.Context) {
612612
"height": h,
613613
"parent": resp.Block.ParentHash().Short(4),
614614
"hash": resp.Block.BlockHash().Short(4),
615-
}).Debug("Fetched new block from remote peer")
615+
}).Debug("fetched new block from remote peer")
616616
select {
617617
case c.pendingBlocks <- resp.Block:
618618
case <-cld.Done():
619-
log.WithError(cld.Err()).Warn("Add pending block aborted")
619+
log.WithError(cld.Err()).Warn("add pending block aborted")
620620
}
621621
}(v)
622622
}
@@ -626,11 +626,11 @@ func (c *Chain) syncCurrentHead(ctx context.Context) {
626626
// Stop stops the main process of the sql-chain.
627627
func (c *Chain) Stop() (err error) {
628628
// Stop main process
629-
log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Stopping chain")
629+
log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("stopping chain")
630630
c.stop()
631-
log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Chain service stopped")
631+
log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain service stopped")
632632
c.st.Close()
633-
log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Chain database closed")
633+
log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain database closed")
634634
close(c.pendingBlocks)
635635
close(c.pendingTxs)
636636
return
@@ -694,7 +694,7 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
694694
for _, b := range newIrres {
695695
for _, tx := range b.block.Transactions {
696696
if err := c.immutable.apply(tx); err != nil {
697-
log.WithError(err).Fatal("Failed to apply block to immutable database")
697+
log.WithError(err).Fatal("failed to apply block to immutable database")
698698
}
699699
}
700700
}
@@ -753,7 +753,7 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
753753
}
754754
return fmt.Sprintf("[%04d]", i)
755755
}(),
756-
}).Debugf("Pruning branch")
756+
}).Debugf("pruning branch")
757757
}
758758
}
759759
// Replace current branches
@@ -793,7 +793,7 @@ func (c *Chain) stat() {
793793
buff += v.sprint(c.lastIrre.count)
794794
log.WithFields(log.Fields{
795795
"branch": buff,
796-
}).Info("Runtime state")
796+
}).Info("runtime state")
797797
}
798798
return
799799
}

blockproducer/storage.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func store(st xi.Storage, sps []storageProcedure, cb storageCallback) (err error
9595
}
9696
// COMMIT
9797
if err = tx.Commit(); err != nil {
98-
log.WithError(err).Fatalf("Failed to commit storage transaction")
98+
log.WithError(err).Fatalf("failed to commit storage transaction")
9999
}
100100
return
101101
}
@@ -349,7 +349,7 @@ func loadBlocks(
349349
"height": v1,
350350
"hash": bh.Short(4),
351351
"parent": ph.Short(4),
352-
}).Debug("Loaded new block")
352+
}).Debug("loaded new block")
353353
// Add genesis block
354354
if v1 == 0 {
355355
if len(index) != 0 {
@@ -364,7 +364,7 @@ func loadBlocks(
364364
"height": v1,
365365
"hash": bh.Short(4),
366366
"parent": ph.Short(4),
367-
}).Debug("Set genesis block")
367+
}).Debug("set genesis block")
368368
continue
369369
}
370370
// Add normal block

cmd/cql-adapter/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func main() {
5656
}
5757

5858
flag.Visit(func(f *flag.Flag) {
59-
log.Infof("Args %#v : %s", f.Name, f.Value)
59+
log.Infof("args %#v : %s", f.Name, f.Value)
6060
})
6161

6262
server, err := NewHTTPAdapter(configFile, password)

cmd/cql-explorer/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func main() {
6666
}
6767

6868
flag.Visit(func(f *flag.Flag) {
69-
log.Infof("Args %#v : %s", f.Name, f.Value)
69+
log.Infof("args %#v : %s", f.Name, f.Value)
7070
})
7171

7272
// init client

cmd/cql-faucet/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func main() {
5858
}
5959

6060
flag.Visit(func(f *flag.Flag) {
61-
log.Infof("Args %#v : %s", f.Name, f.Value)
61+
log.Infof("args %#v : %s", f.Name, f.Value)
6262
})
6363

6464
// init client

cmd/cql-fuse/block_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,15 @@ func TestReadWriteBlocks(t *testing.T) {
445445
log.Fatal(err)
446446
}
447447
if !bytes.Equal(part1, readData) {
448-
t.Errorf("Bytes differ. lengths: %d, expected %d", len(readData), len(part1))
448+
t.Errorf("bytes differ. lengths: %d, expected %d", len(readData), len(part1))
449449
}
450450

451451
verboseData, err := getAllBlocks(db, id)
452452
if err != nil {
453453
log.Fatal(err)
454454
}
455455
if !bytes.Equal(verboseData, part1) {
456-
t.Errorf("Bytes differ. lengths: %d, expected %d", len(verboseData), len(part1))
456+
t.Errorf("bytes differ. lengths: %d, expected %d", len(verboseData), len(part1))
457457
}
458458

459459
// Write with hole in the middle.
@@ -469,15 +469,15 @@ func TestReadWriteBlocks(t *testing.T) {
469469
log.Fatal(err)
470470
}
471471
if !bytes.Equal(fullData, readData) {
472-
t.Errorf("Bytes differ. lengths: %d, expected %d", len(readData), len(fullData))
472+
t.Errorf("bytes differ. lengths: %d, expected %d", len(readData), len(fullData))
473473
}
474474

475475
verboseData, err = getAllBlocks(db, id)
476476
if err != nil {
477477
log.Fatal(err)
478478
}
479479
if !bytes.Equal(verboseData, fullData) {
480-
t.Errorf("Bytes differ. lengths: %d, expected %d", len(verboseData), len(fullData))
480+
t.Errorf("bytes differ. lengths: %d, expected %d", len(verboseData), len(fullData))
481481
}
482482

483483
// Now write into the middle of the file.
@@ -492,15 +492,15 @@ func TestReadWriteBlocks(t *testing.T) {
492492
log.Fatal(err)
493493
}
494494
if !bytes.Equal(fullData, readData) {
495-
t.Errorf("Bytes differ. lengths: %d, expected %d", len(readData), len(fullData))
495+
t.Errorf("bytes differ. lengths: %d, expected %d", len(readData), len(fullData))
496496
}
497497

498498
verboseData, err = getAllBlocks(db, id)
499499
if err != nil {
500500
log.Fatal(err)
501501
}
502502
if !bytes.Equal(verboseData, fullData) {
503-
t.Errorf("Bytes differ. lengths: %d, expected %d", len(verboseData), len(fullData))
503+
t.Errorf("bytes differ. lengths: %d, expected %d", len(verboseData), len(fullData))
504504
}
505505

506506
// New file.

cmd/cql-minerd/integration_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) {
497497
_, err = db.Exec("INSERT INTO "+TABLENAME+" ( k, v1 ) VALUES"+
498498
"(?, ?)", index, ii,
499499
)
500-
//log.Warnf("Insert index = %d %v", index, time.Since(start))
500+
//log.Warnf("insert index = %d %v", index, time.Since(start))
501501
for err != nil && err.Error() == sqlite3.ErrBusy.Error() {
502502
// retry forever
503503
log.Warnf("index = %d retried", index)
@@ -525,7 +525,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) {
525525
if err != nil {
526526
b.Fatal(err)
527527
}
528-
log.Warnf("Row Count: %v", count)
528+
log.Warnf("row Count: %v", count)
529529

530530
b.Run("benchmark SELECT", func(b *testing.B) {
531531
b.ResetTimer()
@@ -540,7 +540,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) {
540540
//log.Debugf("index = %d", index)
541541
//start := time.Now()
542542
row := db.QueryRow("SELECT v1 FROM "+TABLENAME+" WHERE k = ? LIMIT 1", index)
543-
//log.Warnf("Select index = %d %v", index, time.Since(start))
543+
//log.Warnf("select index = %d %v", index, time.Since(start))
544544
var result []byte
545545
err = row.Scan(&result)
546546
if err != nil || (len(result) == 0) {
@@ -570,7 +570,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) {
570570
}
571571

572572
func benchMiner(b *testing.B, minerCount uint16, bypassSign bool) {
573-
log.Warnf("Benchmark for %d Miners, BypassSignature: %v", minerCount, bypassSign)
573+
log.Warnf("benchmark for %d Miners, BypassSignature: %v", minerCount, bypassSign)
574574
asymmetric.BypassSignature = bypassSign
575575
if minerCount > 0 {
576576
startNodesProfile(bypassSign)
@@ -647,7 +647,7 @@ func BenchmarkSQLite(b *testing.B) {
647647
} else {
648648
f.Close()
649649
db, err = sql.Open("sqlite3", millionFile+"?_journal_mode=WAL&_synchronous=NORMAL&cache=shared")
650-
log.Infof("Testing sqlite3 million data exist file %v", millionFile)
650+
log.Infof("testing sqlite3 million data exist file %v", millionFile)
651651
if err != nil {
652652
log.Fatal(err)
653653
}
@@ -661,7 +661,7 @@ func BenchmarkSQLite(b *testing.B) {
661661
}
662662

663663
func benchGNTEMiner(b *testing.B, minerCount uint16, bypassSign bool) {
664-
log.Warnf("Benchmark GNTE for %d Miners, BypassSignature: %v", minerCount, bypassSign)
664+
log.Warnf("benchmark GNTE for %d Miners, BypassSignature: %v", minerCount, bypassSign)
665665
asymmetric.BypassSignature = bypassSign
666666

667667
// Create temp directory

cmd/cql-minerd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func main() {
127127
}
128128

129129
flag.Visit(func(f *flag.Flag) {
130-
log.Infof("Args %#v : %s", f.Name, f.Value)
130+
log.Infof("args %#v : %s", f.Name, f.Value)
131131
})
132132

133133
var err error

cmd/cql-mysql-adapter/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func main() {
6363
}
6464

6565
flag.Visit(func(f *flag.Flag) {
66-
log.Infof("Args %#v : %s", f.Name, f.Value)
66+
log.Infof("args %#v : %s", f.Name, f.Value)
6767
})
6868

6969
// init client

cmd/cql-observer/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ func loadConfig(path string) (config *Config, err error) {
4444
wrapper = &configWrapper{}
4545
)
4646
if content, err = ioutil.ReadFile(path); err != nil {
47-
log.WithError(err).Error("Failed to read config file")
47+
log.WithError(err).Error("failed to read config file")
4848
return
4949
}
5050
if err = yaml.Unmarshal(content, wrapper); err != nil {
51-
log.WithError(err).Error("Failed to unmarshal config file")
51+
log.WithError(err).Error("failed to unmarshal config file")
5252
return
5353
}
5454
config = wrapper.Observer

0 commit comments

Comments
 (0)