add a super verbose -vv flag to lotus and lotus-miner.
This commit is contained in:
parent
e4ebbf106a
commit
48cddd3644
@ -146,6 +146,10 @@ func GetRawAPI(ctx *cli.Context, t repo.RepoType, version string) (string, http.
|
|||||||
return "", nil, xerrors.Errorf("could not get DialArgs: %w", err)
|
return "", nil, xerrors.Errorf("could not get DialArgs: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if IsSuperVerbose {
|
||||||
|
_, _ = fmt.Fprintf(ctx.App.Writer, "using raw API %s endpoint: %s\n", version, addr)
|
||||||
|
}
|
||||||
|
|
||||||
return addr, ainfo.AuthHeader(), nil
|
return addr, ainfo.AuthHeader(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +189,10 @@ func GetFullNodeAPI(ctx *cli.Context) (v0api.FullNode, jsonrpc.ClientCloser, err
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if IsSuperVerbose {
|
||||||
|
_, _ = fmt.Fprintln(ctx.App.Writer, "using full node API v0 endpoint:", addr)
|
||||||
|
}
|
||||||
|
|
||||||
return client.NewFullNodeRPCV0(ctx.Context, addr, headers)
|
return client.NewFullNodeRPCV0(ctx.Context, addr, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +206,10 @@ func GetFullNodeAPIV1(ctx *cli.Context) (v1api.FullNode, jsonrpc.ClientCloser, e
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if IsSuperVerbose {
|
||||||
|
_, _ = fmt.Fprintln(ctx.App.Writer, "using full node API v1 endpoint:", addr)
|
||||||
|
}
|
||||||
|
|
||||||
return client.NewFullNodeRPCV1(ctx.Context, addr, headers)
|
return client.NewFullNodeRPCV1(ctx.Context, addr, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,6 +254,10 @@ func GetStorageMinerAPI(ctx *cli.Context, opts ...GetStorageMinerOption) (api.St
|
|||||||
addr = u.String()
|
addr = u.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if IsSuperVerbose {
|
||||||
|
_, _ = fmt.Fprintln(ctx.App.Writer, "using miner API v0 endpoint:", addr)
|
||||||
|
}
|
||||||
|
|
||||||
return client.NewStorageMinerRPCV0(ctx.Context, addr, headers)
|
return client.NewStorageMinerRPCV0(ctx.Context, addr, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,6 +267,10 @@ func GetWorkerAPI(ctx *cli.Context) (api.Worker, jsonrpc.ClientCloser, error) {
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if IsSuperVerbose {
|
||||||
|
_, _ = fmt.Fprintln(ctx.App.Writer, "using worker API v0 endpoint:", addr)
|
||||||
|
}
|
||||||
|
|
||||||
return client.NewWorkerRPCV0(ctx.Context, addr, headers)
|
return client.NewWorkerRPCV0(ctx.Context, addr, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,6 +280,10 @@ func GetGatewayAPI(ctx *cli.Context) (api.Gateway, jsonrpc.ClientCloser, error)
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if IsSuperVerbose {
|
||||||
|
_, _ = fmt.Fprintln(ctx.App.Writer, "using gateway API v1 endpoint:", addr)
|
||||||
|
}
|
||||||
|
|
||||||
return client.NewGatewayRPCV1(ctx.Context, addr, headers)
|
return client.NewGatewayRPCV1(ctx.Context, addr, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +293,10 @@ func GetGatewayAPIV0(ctx *cli.Context) (v0api.Gateway, jsonrpc.ClientCloser, err
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if IsSuperVerbose {
|
||||||
|
_, _ = fmt.Fprintln(ctx.App.Writer, "using gateway API v0 endpoint:", addr)
|
||||||
|
}
|
||||||
|
|
||||||
return client.NewGatewayRPCV0(ctx.Context, addr, headers)
|
return client.NewGatewayRPCV0(ctx.Context, addr, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
cli/util/verbose.go
Normal file
16
cli/util/verbose.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package cliutil
|
||||||
|
|
||||||
|
import "github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
// IsSuperVerbose is a global var signalling if we're running in super verbose
|
||||||
|
// mode or not (default: false).
|
||||||
|
var IsSuperVerbose bool
|
||||||
|
|
||||||
|
// FlagSuperVerbose enables super verbose mode, which is useful when debugging
|
||||||
|
// the CLI itself. It should be included as a flag on the top-level command
|
||||||
|
// (e.g. lotus -vv, lotus-miner -vv).
|
||||||
|
var FlagSuperVerbose = &cli.BoolFlag{
|
||||||
|
Name: "vv",
|
||||||
|
Usage: "enables super verbose mode, useful for debugging the CLI",
|
||||||
|
Destination: &IsSuperVerbose,
|
||||||
|
}
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
|
cliutil "github.com/filecoin-project/lotus/cli/util"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
@ -105,6 +106,7 @@ func main() {
|
|||||||
Value: "~/.lotusminer", // TODO: Consider XDG_DATA_HOME
|
Value: "~/.lotusminer", // TODO: Consider XDG_DATA_HOME
|
||||||
Usage: fmt.Sprintf("Specify miner repo path. flag(%s) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON", FlagMinerRepoDeprecation),
|
Usage: fmt.Sprintf("Specify miner repo path. flag(%s) and env(LOTUS_STORAGE_PATH) are DEPRECATION, will REMOVE SOON", FlagMinerRepoDeprecation),
|
||||||
},
|
},
|
||||||
|
cliutil.FlagSuperVerbose,
|
||||||
},
|
},
|
||||||
|
|
||||||
Commands: append(local, lcli.CommonCommands...),
|
Commands: append(local, lcli.CommonCommands...),
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
|
cliutil "github.com/filecoin-project/lotus/cli/util"
|
||||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||||
"github.com/filecoin-project/lotus/lib/tracing"
|
"github.com/filecoin-project/lotus/lib/tracing"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
@ -81,6 +82,7 @@ func main() {
|
|||||||
Name: "force-send",
|
Name: "force-send",
|
||||||
Usage: "if true, will ignore pre-send checks",
|
Usage: "if true, will ignore pre-send checks",
|
||||||
},
|
},
|
||||||
|
cliutil.FlagSuperVerbose,
|
||||||
},
|
},
|
||||||
|
|
||||||
Commands: append(local, lcli.Commands...),
|
Commands: append(local, lcli.Commands...),
|
||||||
|
Loading…
Reference in New Issue
Block a user