summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2020-03-04 17:31:02 +0000
committerPaul Buetow <pbuetow@mimecast.com>2020-03-04 17:31:02 +0000
commit9314744d715b839b1708ca64fb6ca71438d8b440 (patch)
treebca57acc5ed88d1202298f0e9ec684c7f74285fd /cmd
parent238dd3930e9c58397a86f649c77912ee32e4d7f0 (diff)
fix silent logging https://github.com/mimecast/dtail/issues/5
Diffstat (limited to 'cmd')
-rw-r--r--cmd/dcat/main.go10
-rw-r--r--cmd/dgrep/main.go9
-rw-r--r--cmd/dmap/main.go10
-rw-r--r--cmd/drun/main.go10
-rw-r--r--cmd/dserver/main.go6
-rw-r--r--cmd/dtail/main.go12
6 files changed, 20 insertions, 37 deletions
diff --git a/cmd/dcat/main.go b/cmd/dcat/main.go
index af46db1..bd29f72 100644
--- a/cmd/dcat/main.go
+++ b/cmd/dcat/main.go
@@ -23,7 +23,7 @@ func main() {
var files string
var noColor bool
var serversStr string
- var silentEnable bool
+ var quietEnable bool
var sshPort int
var trustAllHosts bool
@@ -32,7 +32,7 @@ func main() {
flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages")
flag.BoolVar(&displayVersion, "version", false, "Display version")
flag.BoolVar(&noColor, "noColor", false, "Disable ANSII terminal colors")
- flag.BoolVar(&silentEnable, "silent", false, "Reduce output")
+ flag.BoolVar(&quietEnable, "quiet", false, "Reduce output")
flag.BoolVar(&trustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys")
flag.IntVar(&connectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently")
flag.IntVar(&sshPort, "port", 2222, "SSH server port")
@@ -51,10 +51,8 @@ func main() {
version.PrintAndExit()
}
- ctx := context.Background()
- serverEnable := false
-
- logger.Start(ctx, serverEnable, debugEnable, silentEnable, silentEnable)
+ ctx := context.TODO()
+ logger.Start(ctx, logger.Modes{Debug: debugEnable, Quiet: quietEnable})
args := clients.Args{
ConnectionsPerCPU: connectionsPerCPU,
diff --git a/cmd/dgrep/main.go b/cmd/dgrep/main.go
index 9393cf6..6ba90fc 100644
--- a/cmd/dgrep/main.go
+++ b/cmd/dgrep/main.go
@@ -24,7 +24,7 @@ func main() {
var noColor bool
var regex string
var serversStr string
- var silentEnable bool
+ var quietEnable bool
var sshPort int
var trustAllHosts bool
@@ -33,7 +33,7 @@ func main() {
flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages")
flag.BoolVar(&displayVersion, "version", false, "Display version")
flag.BoolVar(&noColor, "noColor", false, "Disable ANSII terminal colors")
- flag.BoolVar(&silentEnable, "silent", false, "Reduce output")
+ flag.BoolVar(&quietEnable, "quiet", false, "Reduce output")
flag.BoolVar(&trustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys")
flag.IntVar(&connectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently")
flag.IntVar(&sshPort, "port", 2222, "SSH server port")
@@ -53,9 +53,8 @@ func main() {
version.PrintAndExit()
}
- ctx := context.Background()
- serverEnable := false
- logger.Start(ctx, serverEnable, debugEnable, silentEnable, silentEnable)
+ ctx := context.TODO()
+ logger.Start(ctx, logger.Modes{Debug: debugEnable, Quiet: quietEnable})
args := clients.Args{
ConnectionsPerCPU: connectionsPerCPU,
diff --git a/cmd/dmap/main.go b/cmd/dmap/main.go
index dea4706..24f81b8 100644
--- a/cmd/dmap/main.go
+++ b/cmd/dmap/main.go
@@ -25,7 +25,7 @@ func main() {
var noColor bool
var queryStr string
var serversStr string
- var silentEnable bool
+ var quietEnable bool
var sshPort int
var timeout int
var trustAllHosts bool
@@ -35,7 +35,7 @@ func main() {
flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages")
flag.BoolVar(&displayVersion, "version", false, "Display version")
flag.BoolVar(&noColor, "noColor", false, "Disable ANSII terminal colors")
- flag.BoolVar(&silentEnable, "silent", false, "Reduce output")
+ flag.BoolVar(&quietEnable, "quiet", false, "Reduce output")
flag.BoolVar(&trustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys")
flag.IntVar(&connectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently")
flag.IntVar(&sshPort, "port", 2222, "SSH server port")
@@ -56,10 +56,8 @@ func main() {
version.PrintAndExit()
}
- ctx := context.Background()
- serverEnable := false
-
- logger.Start(ctx, serverEnable, debugEnable, silentEnable, silentEnable)
+ ctx := context.TODO()
+ logger.Start(ctx, logger.Modes{Debug: debugEnable, Quiet: quietEnable})
args := clients.Args{
ConnectionsPerCPU: connectionsPerCPU,
diff --git a/cmd/drun/main.go b/cmd/drun/main.go
index 3cc19e7..3817d0e 100644
--- a/cmd/drun/main.go
+++ b/cmd/drun/main.go
@@ -27,7 +27,7 @@ func main() {
var jobName string
var noColor bool
var serversStr string
- var silentEnable bool
+ var quietEnable bool
var sshPort int
var timeout int
var trustAllHosts bool
@@ -37,7 +37,7 @@ func main() {
flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages")
flag.BoolVar(&displayVersion, "version", false, "Display version")
flag.BoolVar(&noColor, "noColor", false, "Disable ANSII terminal colors")
- flag.BoolVar(&silentEnable, "silent", false, "Reduce output")
+ flag.BoolVar(&quietEnable, "quiet", false, "Reduce output")
flag.BoolVar(&trustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys")
flag.IntVar(&connectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently")
flag.IntVar(&sshPort, "port", 2222, "SSH server port")
@@ -59,14 +59,10 @@ func main() {
version.PrintAndExit()
}
- // TODO: Change other commands to use TODO contexts too.
ctx := context.TODO()
- serverEnable := false
-
- logger.Start(ctx, serverEnable, debugEnable, silentEnable, silentEnable)
+ logger.Start(ctx, logger.Modes{Debug: debugEnable, Quiet: quietEnable})
command, commandArgs := readCommand(command)
-
args := clients.Args{
ConnectionsPerCPU: connectionsPerCPU,
ServersStr: serversStr,
diff --git a/cmd/dserver/main.go b/cmd/dserver/main.go
index f9207d5..865bf95 100644
--- a/cmd/dserver/main.go
+++ b/cmd/dserver/main.go
@@ -51,7 +51,6 @@ func main() {
ctx, cancel := context.WithCancel(context.Background())
if shutdownAfter > 0 {
- logger.Info("Enabling auto shutdown timer", shutdownAfter)
ctx, cancel = context.WithTimeout(ctx, time.Duration(shutdownAfter)*time.Second)
}
@@ -66,10 +65,7 @@ func main() {
}
}()
- serverEnable := true
- silentEnable := false
- nothingEnable := false
- logger.Start(ctx, serverEnable, debugEnable, silentEnable, nothingEnable)
+ logger.Start(ctx, logger.Modes{Server: true, Debug: debugEnable})
if pprof > -1 {
// For debugging purposes only
diff --git a/cmd/dtail/main.go b/cmd/dtail/main.go
index f062cdc..bb3cf8c 100644
--- a/cmd/dtail/main.go
+++ b/cmd/dtail/main.go
@@ -32,7 +32,7 @@ func main() {
var queryStr string
var regex string
var serversStr string
- var silentEnable bool
+ var quietEnable bool
var sshPort int
var timeout int
var trustAllHosts bool
@@ -43,7 +43,7 @@ func main() {
flag.BoolVar(&debugEnable, "debug", false, "Activate debug messages")
flag.BoolVar(&displayVersion, "version", false, "Display version")
flag.BoolVar(&noColor, "noColor", false, "Disable ANSII terminal colors")
- flag.BoolVar(&silentEnable, "silent", false, "Reduce output")
+ flag.BoolVar(&quietEnable, "quiet", false, "Reduce output")
flag.BoolVar(&trustAllHosts, "trustAllHosts", false, "Auto trust all unknown host keys")
flag.IntVar(&connectionsPerCPU, "cpc", 10, "How many connections established per CPU core concurrently")
flag.IntVar(&sshPort, "port", 2222, "SSH server port")
@@ -66,18 +66,14 @@ func main() {
version.PrintAndExit()
}
- ctx := context.Background()
+ ctx := context.TODO()
if checkHealth {
healthClient, _ := clients.NewHealthClient(omode.HealthClient)
os.Exit(healthClient.Start(ctx))
}
- serverEnable := false
- if checkHealth {
- silentEnable = true
- }
- logger.Start(ctx, serverEnable, debugEnable, silentEnable, silentEnable)
+ logger.Start(ctx, logger.Modes{Debug: debugEnable, Quiet: quietEnable})
if pprof > -1 {
// For debugging purposes only