mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 04:03:49 +00:00
torrent verbosity allow debug #4569 Open
This commit is contained in:
parent
64697a9647
commit
f613fcafd2
@ -54,7 +54,7 @@ func Default() *torrent.ClientConfig {
|
||||
return torrentConfig
|
||||
}
|
||||
|
||||
func New(snapDir string, verbosity lg.Level, natif nat.Interface, downloadRate, uploadRate datasize.ByteSize, port, connsPerFile, downloadSlots int) (*Cfg, error) {
|
||||
func New(snapDir string, verbosity lg.Level, dbg bool, natif nat.Interface, downloadRate, uploadRate datasize.ByteSize, port, connsPerFile, downloadSlots int) (*Cfg, error) {
|
||||
torrentConfig := Default()
|
||||
// We would-like to reduce amount of goroutines in Erigon, so reducing next params
|
||||
torrentConfig.EstablishedConnsPerTorrent = connsPerFile // default: 50
|
||||
@ -114,9 +114,9 @@ func New(snapDir string, verbosity lg.Level, natif nat.Interface, downloadRate,
|
||||
}
|
||||
|
||||
// debug
|
||||
//if lg.Debug == verbosity {
|
||||
// torrentConfig.Debug = true
|
||||
//}
|
||||
if dbg {
|
||||
torrentConfig.Debug = true
|
||||
}
|
||||
torrentConfig.Logger = lg.Default.FilterLevel(verbosity)
|
||||
torrentConfig.Logger.Handlers = []lg.Handler{adapterHandler{}}
|
||||
|
||||
|
@ -14,26 +14,25 @@ func init() {
|
||||
utp.Logger.Handlers = []lg.Handler{noopHandler{}}
|
||||
}
|
||||
|
||||
func Int2LogLevel(level int) (lg.Level, error) {
|
||||
lvl := lg.Level{}
|
||||
|
||||
func Int2LogLevel(level int) (lvl lg.Level, dbg bool, err error) {
|
||||
switch level {
|
||||
case 0:
|
||||
lvl = lg.NotSet
|
||||
case 1:
|
||||
lvl = lg.Critical
|
||||
case 2:
|
||||
case 1:
|
||||
lvl = lg.Error
|
||||
case 3:
|
||||
case 2:
|
||||
lvl = lg.Warning
|
||||
case 4:
|
||||
case 3:
|
||||
lvl = lg.Info
|
||||
case 4:
|
||||
lvl = lg.Debug
|
||||
case 5:
|
||||
lvl = lg.Debug
|
||||
dbg = true
|
||||
default:
|
||||
return lvl, fmt.Errorf("invalid level set, expected a number between 0-5 but got: %d", level)
|
||||
return lvl, dbg, fmt.Errorf("invalid level set, expected a number between 0-5 but got: %d", level)
|
||||
}
|
||||
return lvl, nil
|
||||
return lvl, dbg, nil
|
||||
}
|
||||
|
||||
type noopHandler struct{}
|
||||
|
@ -114,7 +114,7 @@ var rootCmd = &cobra.Command{
|
||||
|
||||
func Downloader(ctx context.Context) error {
|
||||
dirs := datadir.New(datadirCli)
|
||||
torrentLogLevel, err := downloadercfg.Int2LogLevel(torrentVerbosity)
|
||||
torrentLogLevel, dbg, err := downloadercfg.Int2LogLevel(torrentVerbosity)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -134,7 +134,7 @@ func Downloader(ctx context.Context) error {
|
||||
return fmt.Errorf("invalid nat option %s: %w", natSetting, err)
|
||||
}
|
||||
|
||||
cfg, err := downloadercfg.New(dirs.Snap, torrentLogLevel, natif, downloadRate, uploadRate, torrentPort, torrentConnsPerFile, torrentDownloadSlots)
|
||||
cfg, err := downloadercfg.New(dirs.Snap, torrentLogLevel, dbg, natif, downloadRate, uploadRate, torrentPort, torrentConnsPerFile, torrentDownloadSlots)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ var (
|
||||
}
|
||||
TorrentVerbosityFlag = cli.IntFlag{
|
||||
Name: "torrent.verbosity",
|
||||
Value: 3,
|
||||
Value: 2,
|
||||
Usage: "0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail (must set --verbosity to equal or higher level and has defeault: 3)",
|
||||
}
|
||||
TorrentDownloadRateFlag = cli.StringFlag{
|
||||
@ -1401,11 +1401,11 @@ func SetEthConfig(ctx *cli.Context, nodeConfig *nodecfg.Config, cfg *ethconfig.C
|
||||
panic(err)
|
||||
}
|
||||
log.Info("torrent verbosity", "level", ctx.GlobalInt(TorrentVerbosityFlag.Name))
|
||||
lvl, err := downloadercfg.Int2LogLevel(ctx.GlobalInt(TorrentVerbosityFlag.Name))
|
||||
lvl, dbg, err := downloadercfg.Int2LogLevel(ctx.GlobalInt(TorrentVerbosityFlag.Name))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cfg.Downloader, err = downloadercfg.New(cfg.Dirs.Snap, lvl, nodeConfig.P2P.NAT, downloadRate, uploadRate, ctx.GlobalInt(TorrentPortFlag.Name), ctx.GlobalInt(TorrentConnsPerFileFlag.Name), ctx.GlobalInt(TorrentDownloadSlotsFlag.Name))
|
||||
cfg.Downloader, err = downloadercfg.New(cfg.Dirs.Snap, lvl, dbg, nodeConfig.P2P.NAT, downloadRate, uploadRate, ctx.GlobalInt(TorrentPortFlag.Name), ctx.GlobalInt(TorrentConnsPerFileFlag.Name), ctx.GlobalInt(TorrentDownloadSlotsFlag.Name))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user