-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcmd.go
65 lines (58 loc) · 1.71 KB
/
cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"io"
"os"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/log"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"gopkg.in/urfave/cli.v1"
)
var (
// LogLevelFlag sets log level for server
LogLevelFlag = cli.IntFlag{
Name: "loglevel",
Value: 3,
Usage: "log level to emit to the screen",
}
// RPCPortFlag sets port for http operation
RPCPortFlag = cli.IntFlag{
Name: "rpcport",
Usage: "HTTP-RPC server listening port",
Value: 9797,
}
// IPCPathFlag sets ipc path for an ipc rpc server
IPCPathFlag = utils.DirectoryFlag{
Name: "ipcpath",
Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
}
// HTTPListenAddrFlag sets address http address to listen on
HTTPListenAddrFlag = cli.StringFlag{
Name: "http.addr",
Usage: "HTTP-RPC server listening interface",
Value: "localhost",
}
// BucketNameFlag sets namespace for S3 bucket
BucketNameFlag = cli.StringFlag{
Name: "bucket",
Usage: "Storj bucket name",
}
)
func checkBucketArg(c *cli.Context) (bucketName string) {
bucketName = c.GlobalString(BucketNameFlag.Name)
if bucketName == "" {
utils.Fatalf("Missing bucket please specify a bucket, with --bucket")
}
return
}
func setupLogFormat(c *cli.Context) error {
// Set up the logger to print everything
logOutput := os.Stdout
usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb"
output := io.Writer(logOutput)
if usecolor {
output = colorable.NewColorable(logOutput)
}
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int(LogLevelFlag.Name)), log.StreamHandler(output, log.TerminalFormat(usecolor))))
return nil
}