Skip to content

Commit

Permalink
*Fixed Windows compatibility for logging
Browse files Browse the repository at this point in the history
*Removed deprecated files
*Fixed make file cross-compile settings
  • Loading branch information
Vladimir Ovcharov committed Nov 19, 2018
1 parent 582ca7a commit 7c4cb92
Show file tree
Hide file tree
Showing 28 changed files with 238 additions and 437 deletions.
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ devtools:


# Cross Compilation Targets (xgo)
sn-cross: sness-linux sness-darwin sness-windows sness-android sness-ios
@echo "Full cross compilation done:"
@ls -ld $(GOBIN)/sness*
sn-cross: sness-linux sness-darwin sness-windows #sness-android sness-ios
@echo "Full cross compilation done"

sn-linux: sn-linux-386 sn-linux-amd64 sn-linux-arm #sn-linux-mips sn-linux-mips64 sn-linux-mips64le
@echo "Linux cross compilation done:"
Expand Down
59 changes: 0 additions & 59 deletions contracts/voter-registration-contract/deployVRC/README.md

This file was deleted.

145 changes: 0 additions & 145 deletions contracts/voter-registration-contract/deployVRC/deployVRC.go

This file was deleted.

2 changes: 1 addition & 1 deletion shared/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

var (
// VerbosityFlag defines the logrus configuration.
// VerbosityFlag defines the log configuration.
VerbosityFlag = cli.StringFlag{
Name: "verbosity",
Usage: "Logging verbosity (debug, info=default, warn, error, fatal, panic)",
Expand Down
9 changes: 5 additions & 4 deletions shared/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"fmt"
"path/filepath"

"github.com/mattn/go-colorable"
"github.com/ovcharovvladimir/essentiaHybrid/essdb"
"github.com/sirupsen/logrus"
"github.com/ovcharovvladimir/essentiaHybrid/log"
"gopkg.in/urfave/cli.v1"
)

var log = logrus.WithField("prefix", "db")

// DB defines a service for the beacon chain system's persistent storage.
type DB struct {
_db essdb.Database
Expand All @@ -26,6 +26,7 @@ type DBConfig struct {

// NewDB initializes a beaconDB instance.
func NewDB(config *DBConfig) (*DB, error) {
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(3), log.StreamHandler(colorable.NewColorableStdout(), log.TerminalFormat(true))))
// Uses default cache and handles values.
db := &DB{}
if config.InMemory {
Expand All @@ -35,7 +36,7 @@ func NewDB(config *DBConfig) (*DB, error) {

_db, err := essdb.NewLDBDatabase(filepath.Join(config.DataDir, config.Name), 16, 16)
if err != nil {
log.Error(fmt.Sprintf("Could not start beaconDB: %v", err))
log.Error("Could not start beaconDB", "err", err)
return nil, err
}
db._db = _db
Expand Down
20 changes: 13 additions & 7 deletions shared/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ import (
"time"

"github.com/fjl/memsize/memsizeui"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/mattn/go-colorable"
"github.com/ovcharovvladimir/essentiaHybrid/log"

"gopkg.in/urfave/cli.v1"
)

// Handler is the global debugging handler.
Expand Down Expand Up @@ -99,6 +101,7 @@ func (*HandlerT) MemStats() *runtime.MemStats {

// GcStats returns GC statistics.
func (*HandlerT) GcStats() *debug.GCStats {

s := new(debug.GCStats)
debug.ReadGCStats(s)
return s
Expand All @@ -107,6 +110,7 @@ func (*HandlerT) GcStats() *debug.GCStats {
// CPUProfile turns on CPU profiling for nsec seconds and writes
// profile data to file.
func (h *HandlerT) CPUProfile(file string, nsec uint) error {

if err := h.StartCPUProfile(file); err != nil {
return err
}
Expand All @@ -127,7 +131,7 @@ func (h *HandlerT) StartCPUProfile(file string) error {
}
if err := pprof.StartCPUProfile(f); err != nil {
if err := f.Close(); err != nil {
log.Errorf("Failed to close file: %v", err)
log.Error("Failed to close file", "err", err)
}
return err
}
Expand Down Expand Up @@ -177,7 +181,7 @@ func (h *HandlerT) StartGoTrace(file string) error {
}
if err := trace.Start(f); err != nil {
if err := f.Close(); err != nil {
log.Errorf("Failed to close file: %v", err)
log.Error("Failed to close file", "err", err)
}
return err
}
Expand Down Expand Up @@ -208,6 +212,7 @@ func (h *HandlerT) StopGoTrace() error {
// file. It uses a profile rate of 1 for most accurate information. If a different rate is
// desired, set the rate and write the profile manually.
func (*HandlerT) BlockProfile(file string, nsec uint) error {

runtime.SetBlockProfileRate(1)
time.Sleep(time.Duration(nsec) * time.Second)
defer runtime.SetBlockProfileRate(0)
Expand Down Expand Up @@ -256,7 +261,7 @@ func (*HandlerT) WriteMemProfile(file string) error {
func (*HandlerT) Stacks() string {
buf := new(bytes.Buffer)
if err := pprof.Lookup("goroutine").WriteTo(buf, 2); err != nil {
log.Errorf("Failed to write pprof goroutine stacks: %v", err)
log.Error("Failed to write pprof goroutine stacks: %v", err)
}
return buf.String()
}
Expand Down Expand Up @@ -331,6 +336,7 @@ func MigrateFlags(action func(ctx *cli.Context) error) func(*cli.Context) error
// Setup initializes profiling based on the CLI flags.
// It should be called as early as possible in the program.
func Setup(ctx *cli.Context) error {
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(3), log.StreamHandler(colorable.NewColorableStdout(), log.TerminalFormat(true))))
// profiling, tracing
runtime.MemProfileRate = ctx.GlobalInt(MemProfileRateFlag.Name)
if traceFile := ctx.GlobalString(TraceFlag.Name); traceFile != "" {
Expand Down Expand Up @@ -367,12 +373,12 @@ func startPProf(address string) {
func Exit(ctx *cli.Context) {
if traceFile := ctx.GlobalString(TraceFlag.Name); traceFile != "" {
if err := Handler.StopGoTrace(); err != nil {
log.Errorf("Failed to stop go tracing: %v", err)
log.Error("Failed to stop go tracing", err)
}
}
if cpuFile := ctx.GlobalString(CPUProfileFlag.Name); cpuFile != "" {
if err := Handler.StopCPUProfile(); err != nil {
log.Errorf("Failed to stop CPU profiling: %v", err)
log.Error("Failed to stop CPU profiling", err)
}
}
}
9 changes: 5 additions & 4 deletions shared/p2p/adapter/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package tracer
import (
"errors"

"github.com/mattn/go-colorable"
"github.com/ovcharovvladimir/Prysm/shared/p2p"
"github.com/sirupsen/logrus"
"github.com/ovcharovvladimir/essentiaHybrid/log"
"go.opencensus.io/exporter/jaeger"
"go.opencensus.io/trace"
)

var log = logrus.WithField("prefix", "tracer")

// New creates and initializes a new tracing adapter.
func New(name, endpoint string, sampleFraction float64, enable bool) (p2p.Adapter, error) {
// Set up the logger
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(3), log.StreamHandler(colorable.NewColorableStdout(), log.TerminalFormat(true))))
if !enable {
trace.ApplyConfig(trace.Config{DefaultSampler: trace.NeverSample()})
return adapter, nil
Expand All @@ -24,7 +25,7 @@ func New(name, endpoint string, sampleFraction float64, enable bool) (p2p.Adapte

trace.ApplyConfig(trace.Config{DefaultSampler: trace.ProbabilitySampler(sampleFraction)})

log.Infof("Starting Jaeger exporter endpoint at address = %s", endpoint)
log.Info("Starting Jaeger exporter endpoint at address = ", endpoint)
exporter, err := jaeger.NewExporter(jaeger.Options{
Endpoint: endpoint,
Process: jaeger.Process{
Expand Down

0 comments on commit 7c4cb92

Please sign in to comment.