diff --git a/main.go b/main.go index b59a26f6a17..2486730aeb6 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,9 @@ Logging Options: -r, --remote_syslog Syslog server addr (udp://localhost:514) -D, --debug Enable debugging output -V, --trace Trace the raw protocol + -VV Verbose trace (traces system account as well) -DV Debug and trace + -DVV Debug and verbose trace (traces system account as well) Authorization Options: --user User required for connections diff --git a/server/client.go b/server/client.go index 02b6058a70e..309d1f0527a 100644 --- a/server/client.go +++ b/server/client.go @@ -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.traceSysAcc { + 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. diff --git a/server/events.go b/server/events.go index a15653cebec..e3c60354435 100644 --- a/server/events.go +++ b/server/events.go @@ -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) diff --git a/server/log.go b/server/log.go index 762cce95e6a..928efd52af4 100644 --- a/server/log.go +++ b/server/log.go @@ -86,6 +86,8 @@ func (s *Server) ConfigureLogger() { } s.SetLogger(log, opts.Debug, opts.Trace) + + s.logging.traceSysAcc = opts.TraceVerbose } // SetLogger sets the logger of the server diff --git a/server/opts.go b/server/opts.go index 9ffe4cab77d..c2d888cc822 100644 --- a/server/opts.go +++ b/server/opts.go @@ -149,6 +149,7 @@ type Options struct { ClientAdvertise string `json:"-"` Trace bool `json:"-"` Debug bool `json:"-"` + TraceVerbose bool `json:"-"` NoLog bool `json:"-"` NoSigs bool `json:"-"` NoSublistCache bool `json:"-"` @@ -513,6 +514,11 @@ func (o *Options) processConfigFileLine(k string, v interface{}, errors *[]error case "trace": o.Trace = v.(bool) trackExplicitVal(o, &o.inConfig, "Trace", o.Trace) + case "trace_verbose": + o.TraceVerbose = v.(bool) + o.Trace = v.(bool) + trackExplicitVal(o, &o.inConfig, "TraceVerbose", o.TraceVerbose) + trackExplicitVal(o, &o.inConfig, "Trace", o.Trace) case "logtime": o.Logtime = v.(bool) trackExplicitVal(o, &o.inConfig, "Logtime", o.Logtime) @@ -3020,13 +3026,15 @@ func setBaselineOptions(opts *Options) { func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, printTLSHelp func()) (*Options, error) { opts := &Options{} var ( - showVersion bool - showHelp bool - showTLSHelp bool - signal string - configFile string - dbgAndTrace bool - err error + showVersion bool + showHelp bool + showTLSHelp bool + signal string + configFile string + dbgAndTrace bool + trcAndVerboseTrc bool + dbgAndTrcAndVerboseTrc bool + err error ) fs.BoolVar(&showHelp, "h", false, "Show this message.") @@ -3040,8 +3048,10 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, fs.BoolVar(&opts.Debug, "D", false, "Enable Debug logging.") fs.BoolVar(&opts.Debug, "debug", false, "Enable Debug logging.") fs.BoolVar(&opts.Trace, "V", false, "Enable Trace logging.") + fs.BoolVar(&trcAndVerboseTrc, "VV", false, "Enable Verbose Trace logging. (Traces system account as well)") fs.BoolVar(&opts.Trace, "trace", false, "Enable Trace logging.") fs.BoolVar(&dbgAndTrace, "DV", false, "Enable Debug and Trace logging.") + fs.BoolVar(&dbgAndTrcAndVerboseTrc, "DVV", false, "Enable Debug and Verbose Trace logging. (Traces system account as well)") 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.") @@ -3129,6 +3139,10 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, // Keep track of the boolean flags that were explicitly set with their value. fs.Visit(func(f *flag.Flag) { switch f.Name { + case "DVV": + trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "Debug", dbgAndTrcAndVerboseTrc) + trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "Trace", dbgAndTrcAndVerboseTrc) + trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "TraceVerbose", dbgAndTrcAndVerboseTrc) case "DV": trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "Debug", dbgAndTrace) trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "Trace", dbgAndTrace) @@ -3136,6 +3150,9 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, fallthrough case "debug": trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "Debug", FlagSnapshot.Debug) + case "VV": + trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "Trace", trcAndVerboseTrc) + trackExplicitVal(FlagSnapshot, &FlagSnapshot.inCmdLine, "TraceVerbose", trcAndVerboseTrc) case "V": fallthrough case "trace": @@ -3216,6 +3233,10 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, } } else { switch f.Name { + case "VV": + opts.Trace, opts.TraceVerbose = trcAndVerboseTrc, trcAndVerboseTrc + case "DVV": + opts.Trace, opts.Debug, opts.TraceVerbose = dbgAndTrcAndVerboseTrc, dbgAndTrcAndVerboseTrc, dbgAndTrcAndVerboseTrc case "DV": // Check value to support -DV=false opts.Trace, opts.Debug = dbgAndTrace, dbgAndTrace diff --git a/server/server.go b/server/server.go index ad2fb476bdc..c94c1ac09a0 100644 --- a/server/server.go +++ b/server/server.go @@ -153,9 +153,10 @@ type Server struct { logging struct { sync.RWMutex - logger Logger - trace int32 - debug int32 + logger Logger + trace int32 + debug int32 + traceSysAcc bool } clientConnectURLs []string