delve/pkg/logflags/logflags.go
aarzilli 8ce88095c6 cmd/dlv: Revert 4e177b, use new flag name for debug logging options
Previously to 4e177bb99acc511897f9cdbfc6cbc50d92ae4725 it was possible
to use --log without arguments to enable logging, this commit reenables
that use case.

The new functionality of the --log flag moved to a new flag name
--logx.

Fixes #1188
2018-04-26 09:45:52 -07:00

55 lines
1.1 KiB
Go

package logflags
import (
"errors"
"strings"
)
var debugger = false
var gdbWire = false
var lldbServerOutput = false
// GdbWire returns true if the gdbserial package should log all the packets
// exchanged with the stub.
func GdbWire() bool {
return gdbWire
}
// Debugger returns true if the debugger package should log.
func Debugger() bool {
return debugger
}
// LLDBServerOutput returns true if the output of the LLDB server should be
// redirected to standard output instead of suppressed.
func LLDBServerOutput() bool {
return lldbServerOutput
}
var errLogstrWithoutLog = errors.New("--log-output specified without --log")
// Setup sets debugger flags based on the contents of logstr.
func Setup(log bool, logstr string) error {
if !log {
if logstr != "" {
return errLogstrWithoutLog
}
return nil
}
if logstr == "" {
logstr = "debugger"
}
v := strings.Split(logstr, ",")
for _, logcmd := range v {
switch logcmd {
case "debugger":
debugger = true
case "gdbwire":
gdbWire = true
case "lldbout":
lldbServerOutput = true
}
}
return nil
}