Adding option to enable tracing the system account. (default: false)

Use sys_trace option in config file or --sys_trace on the command line

Signed-off-by: Matthias Hanel <mh@synadia.com>
This commit is contained in:
Matthias Hanel
2020-03-01 19:42:40 -05:00
parent bb432f47e9
commit bf952a3807
6 changed files with 23 additions and 3 deletions

View File

@@ -44,6 +44,7 @@ Logging Options:
-D, --debug Enable debugging output
-V, --trace Trace the raw protocol
-DV Debug and trace
--sys_trace Trace the system account (default: false)
Authorization Options:
--user <user> User required for connections

View File

@@ -453,6 +453,10 @@ func (c *client) initClient() {
c.debug = (atomic.LoadInt32(&c.srv.logging.debug) != 0)
c.trace = (atomic.LoadInt32(&c.srv.logging.trace) != 0)
if c.kind == SYSTEM && !c.srv.logging.traceSystemAcc {
c.trace = false
}
// This is a scratch buffer used for processMsg()
// The msg header starts with "RMSG ", which can be used
// for both local and routes.

View File

@@ -267,6 +267,11 @@ func (s *Server) internalSendLoop(wg *sync.WaitGroup) {
c.pa.reply = []byte(pm.rply)
c.mu.Unlock()
if c.trace {
c.traceInOp(fmt.Sprintf(
"PUB %s %s %d", c.pa.subject, c.pa.reply, c.pa.size), nil)
}
// Add in NL
b = append(b, _CRLF_...)
c.processInboundClientMsg(b)

View File

@@ -86,6 +86,8 @@ func (s *Server) ConfigureLogger() {
}
s.SetLogger(log, opts.Debug, opts.Trace)
s.logging.traceSystemAcc = opts.SysTrace
}
// SetLogger sets the logger of the server

View File

@@ -149,6 +149,7 @@ type Options struct {
ClientAdvertise string `json:"-"`
Trace bool `json:"-"`
Debug bool `json:"-"`
SysTrace bool `json:"-"`
NoLog bool `json:"-"`
NoSigs bool `json:"-"`
NoSublistCache bool `json:"-"`
@@ -513,6 +514,9 @@ func (o *Options) processConfigFileLine(k string, v interface{}, errors *[]error
case "trace":
o.Trace = v.(bool)
trackExplicitVal(o, &o.inConfig, "Trace", o.Trace)
case "sys_trace":
o.SysTrace = v.(bool)
trackExplicitVal(o, &o.inConfig, "SysTrace", o.SysTrace)
case "logtime":
o.Logtime = v.(bool)
trackExplicitVal(o, &o.inConfig, "Logtime", o.Logtime)
@@ -3042,6 +3046,7 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp,
fs.BoolVar(&opts.Trace, "V", false, "Enable Trace logging.")
fs.BoolVar(&opts.Trace, "trace", false, "Enable Trace logging.")
fs.BoolVar(&dbgAndTrace, "DV", false, "Enable Debug and Trace logging.")
fs.BoolVar(&opts.SysTrace, "sys_trace", false, "Trace the system account.")
fs.BoolVar(&opts.Logtime, "T", true, "Timestamp log entries.")
fs.BoolVar(&opts.Logtime, "logtime", true, "Timestamp log entries.")
fs.StringVar(&opts.Username, "user", "", "Username required for connection.")
@@ -3142,6 +3147,8 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp,
trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "Trace", FlagSnapshot.Trace)
case "T":
fallthrough
case "sys_trace":
trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "SysTrace", FlagSnapshot.SysTrace)
case "logtime":
trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "Logtime", FlagSnapshot.Logtime)
case "s":

View File

@@ -153,9 +153,10 @@ type Server struct {
logging struct {
sync.RWMutex
logger Logger
trace int32
debug int32
logger Logger
trace int32
debug int32
traceSystemAcc bool
}
clientConnectURLs []string