Merge pull request #59 from apcera/log-vet-fixes

Updates for new logging to appease govet
This commit is contained in:
Derek Collison
2014-10-29 12:04:50 -07:00
11 changed files with 103 additions and 108 deletions

View File

@@ -43,7 +43,7 @@ func NewFileLogger(filename string, time, debug, trace bool) *Logger {
fileflags := os.O_WRONLY | os.O_APPEND | os.O_CREATE
f, err := os.OpenFile(filename, fileflags, 0660)
if err != nil {
log.Fatal("error opening file: %v", err)
log.Fatalf("error opening file: %v", err)
}
flags := 0
@@ -78,25 +78,25 @@ func setColoredLabelFormats(l *Logger) {
l.traceLabel = fmt.Sprintf(colorFormat, 33, "TRACE")
}
func (l *Logger) Notice(format string, v ...interface{}) {
func (l *Logger) Noticef(format string, v ...interface{}) {
l.logger.Printf(l.infoLabel+format, v...)
}
func (l *Logger) Error(format string, v ...interface{}) {
func (l *Logger) Errorf(format string, v ...interface{}) {
l.logger.Printf(l.errorLabel+format, v...)
}
func (l *Logger) Fatal(format string, v ...interface{}) {
func (l *Logger) Fatalf(format string, v ...interface{}) {
l.logger.Fatalf(l.fatalLabel+format, v)
}
func (l *Logger) Debug(format string, v ...interface{}) {
func (l *Logger) Debugf(format string, v ...interface{}) {
if l.debug == true {
l.logger.Printf(l.debugLabel+format, v...)
}
}
func (l *Logger) Trace(format string, v ...interface{}) {
func (l *Logger) Tracef(format string, v ...interface{}) {
if l.trace == true {
l.logger.Printf(l.traceLabel+format, v...)
}

View File

@@ -46,42 +46,42 @@ func TestStdLoggerWithDebugTraceAndTime(t *testing.T) {
func TestStdLoggerNotice(t *testing.T) {
expectOutput(t, func() {
logger := NewStdLogger(false, false, false, false)
logger.Notice("foo")
logger.Noticef("foo")
}, "[INFO] foo\n")
}
func TestStdLoggerNoticeWithColor(t *testing.T) {
expectOutput(t, func() {
logger := NewStdLogger(false, false, false, true)
logger.Notice("foo")
logger.Noticef("foo")
}, "[\x1b[32mINFO\x1b[0m] foo\n")
}
func TestStdLoggerDebug(t *testing.T) {
expectOutput(t, func() {
logger := NewStdLogger(false, true, false, false)
logger.Debug("foo %s", "bar")
logger.Debugf("foo %s", "bar")
}, "[DEBUG] foo bar\n")
}
func TestStdLoggerDebugWithOutDebug(t *testing.T) {
expectOutput(t, func() {
logger := NewStdLogger(false, false, false, false)
logger.Debug("foo")
logger.Debugf("foo")
}, "")
}
func TestStdLoggerTrace(t *testing.T) {
expectOutput(t, func() {
logger := NewStdLogger(false, false, true, false)
logger.Trace("foo")
logger.Tracef("foo")
}, "[TRACE] foo\n")
}
func TestStdLoggerTraceWithOutDebug(t *testing.T) {
expectOutput(t, func() {
logger := NewStdLogger(false, false, false, false)
logger.Trace("foo")
logger.Tracef("foo")
}, "")
}
@@ -96,7 +96,7 @@ func TestFileLogger(t *testing.T) {
file.Close()
logger := NewFileLogger(file.Name(), false, false, false)
logger.Notice("foo")
logger.Noticef("foo")
buf, err := ioutil.ReadFile(file.Name())
if err != nil {

View File

@@ -59,25 +59,25 @@ func getNetworkAndAddr(fqn string) (network, addr string) {
return
}
func (l *SysLogger) Notice(format string, v ...interface{}) {
func (l *SysLogger) Noticef(format string, v ...interface{}) {
l.writer.Notice(fmt.Sprintf(format, v...))
}
func (l *SysLogger) Fatal(format string, v ...interface{}) {
func (l *SysLogger) Fatalf(format string, v ...interface{}) {
l.writer.Crit(fmt.Sprintf(format, v...))
}
func (l *SysLogger) Error(format string, v ...interface{}) {
func (l *SysLogger) Errorf(format string, v ...interface{}) {
l.writer.Err(fmt.Sprintf(format, v...))
}
func (l *SysLogger) Debug(format string, v ...interface{}) {
func (l *SysLogger) Debugf(format string, v ...interface{}) {
if l.debug {
l.writer.Debug(fmt.Sprintf(format, v...))
}
}
func (l *SysLogger) Trace(format string, v ...interface{}) {
func (l *SysLogger) Tracef(format string, v ...interface{}) {
if l.trace {
l.writer.Notice(fmt.Sprintf(format, v...))
}

View File

@@ -54,7 +54,7 @@ func TestRemoteSysLoggerNotice(t *testing.T) {
startServer(done)
logger := NewRemoteSysLogger(serverFQN, true, true)
logger.Notice("foo %s", "bar")
logger.Noticef("foo %s", "bar")
expectSyslogOutput(t, <-done, "foo bar\n")
}
@@ -63,7 +63,7 @@ func TestRemoteSysLoggerDebug(t *testing.T) {
startServer(done)
logger := NewRemoteSysLogger(serverFQN, true, true)
logger.Debug("foo %s", "qux")
logger.Debugf("foo %s", "qux")
expectSyslogOutput(t, <-done, "foo qux\n")
}
@@ -72,7 +72,7 @@ func TestRemoteSysLoggerDebugDisabled(t *testing.T) {
startServer(done)
logger := NewRemoteSysLogger(serverFQN, false, false)
logger.Debug("foo %s", "qux")
logger.Debugf("foo %s", "qux")
rcvd := <-done
if rcvd != "" {
t.Fatalf("Unexpected syslog response %s\n", rcvd)
@@ -84,7 +84,7 @@ func TestRemoteSysLoggerTrace(t *testing.T) {
startServer(done)
logger := NewRemoteSysLogger(serverFQN, true, true)
logger.Trace("foo %s", "qux")
logger.Tracef("foo %s", "qux")
expectSyslogOutput(t, <-done, "foo qux\n")
}
@@ -93,7 +93,7 @@ func TestRemoteSysLoggerTraceDisabled(t *testing.T) {
startServer(done)
logger := NewRemoteSysLogger(serverFQN, true, false)
logger.Trace("foo %s", "qux")
logger.Tracef("foo %s", "qux")
rcvd := <-done
if rcvd != "" {
t.Fatalf("Unexpected syslog response %s\n", rcvd)

View File

@@ -144,7 +144,7 @@ func (c *client) readLoop() {
return
}
if err := c.parse(b[:n]); err != nil {
Error("Error reading from client: %s", err.Error(), c)
c.Errorf("Error reading from client: %s", err.Error())
// Auth was handled inline
if err != ErrAuthorization {
c.sendErr("Parser Error")
@@ -161,7 +161,7 @@ func (c *client) readLoop() {
err := cp.bw.Flush()
cp.nc.SetWriteDeadline(time.Time{})
if err != nil {
Debug("Error flushing: %v", err)
Debugf("Error flushing: %v", err)
cp.mu.Unlock()
cp.closeConnection()
cp.mu.Lock()
@@ -184,7 +184,7 @@ func (c *client) traceMsg(msg []byte) {
pm := fmt.Sprintf("Processing %s msg: %d", c.typeString(), c.inMsgs)
opa := []interface{}{pm, string(c.pa.subject), string(c.pa.reply), string(msg[:len(msg)-LEN_CR_LF])}
Trace("MSG: %s", opa, c)
Tracef("MSG: %s", opa, c)
}
func (c *client) traceOp(op string, arg []byte) {
@@ -196,7 +196,7 @@ func (c *client) traceOp(op string, arg []byte) {
if arg != nil {
opa = append(opa, fmt.Sprintf("%s %s", op, string(arg)))
}
Trace("OP: %s", opa, c)
Tracef("OP: %s", opa, c)
}
// Process the info message if we are a route.
@@ -214,11 +214,11 @@ func (c *client) processRouteInfo(info *Info) {
c.mu.Unlock()
if s.addRoute(c) {
Debug("Registering remote route %q", info.ID, c)
Debugf("Registering remote route %q", info.ID, c)
// Send our local subscriptions to this route.
s.sendLocalSubsToRoute(c)
} else {
Debug("Detected duplicate remote route %q", info.ID, c)
Debugf("Detected duplicate remote route %q", info.ID, c)
c.closeConnection()
}
}
@@ -236,7 +236,7 @@ func (c *client) processInfo(arg []byte) error {
}
func (c *client) processErr(errStr string) {
Error("Client error %s", errStr, c)
c.Errorf("Client error %s", errStr)
c.closeConnection()
}
@@ -306,7 +306,7 @@ func (c *client) processPing() {
err := c.bw.Flush()
if err != nil {
c.clearConnection()
Debug("Error on Flush, error %s", err.Error(), c)
Debugf("Error on Flush, error %s", err.Error(), c)
}
c.mu.Unlock()
}
@@ -483,7 +483,7 @@ func (c *client) unsubscribe(sub *subscription) {
c.mu.Lock()
defer c.mu.Unlock()
if sub.max > 0 && sub.nm < sub.max {
Debug(
Debugf(
"Deferring actual UNSUB(%s): %d max, %d received\n",
string(sub.subject), sub.max, sub.nm, c,
)
@@ -628,10 +628,10 @@ writeErr:
client.mu.Unlock()
if ne, ok := err.(net.Error); ok && ne.Timeout() {
Notice("Slow Consumer Detected", c)
Noticef("Slow Consumer Detected", c)
client.closeConnection()
} else {
Debug("Error writing msg: %v", err, c)
Debugf("Error writing msg: %v", err, c)
}
}
@@ -739,11 +739,11 @@ func (c *client) processMsg(msg []byte) {
}
if sub.client == nil || sub.client.nc == nil || sub.client.route == nil ||
sub.client.route.remoteID == "" {
Debug("Bad or Missing ROUTER Identity, not processing msg", c)
Debugf("Bad or Missing ROUTER Identity, not processing msg", c)
continue
}
if _, ok := rmap[sub.client.route.remoteID]; ok {
Debug("Ignoring route, already processed", c)
Debugf("Ignoring route, already processed", c)
continue
}
rmap[sub.client.route.remoteID] = routeSeen
@@ -772,12 +772,12 @@ func (c *client) processPingTimer() {
return
}
Debug("Client Ping Timer", c)
Debugf("Client Ping Timer", c)
// Check for violation
c.pout += 1
if c.pout > c.srv.opts.MaxPingsOut {
Debug("Stale Client Connection - Closing", c)
Debugf("Stale Client Connection - Closing", c)
if c.bw != nil {
c.bw.WriteString(fmt.Sprintf("-ERR '%s'\r\n", "Stale Connection"))
c.bw.Flush()
@@ -790,7 +790,7 @@ func (c *client) processPingTimer() {
c.bw.WriteString("PING\r\n")
err := c.bw.Flush()
if err != nil {
Debug("Error on Client Ping Flush, error %s", err)
Debugf("Error on Client Ping Flush, error %s", err)
c.clearConnection()
} else {
// Reset to fire again if all OK.
@@ -862,7 +862,7 @@ func (c *client) closeConnection() {
return
}
Debug("%s connection closed", c.typeString(), c)
Debugf("%s connection closed", c.typeString(), c)
c.clearAuthTimer()
c.clearPingTimer()
@@ -899,11 +899,16 @@ func (c *client) closeConnection() {
defer srv.mu.Unlock()
rid := c.route.remoteID
if rid != "" && srv.remotes[rid] != nil {
Debug("Not attempting reconnect for solicited route, already connected. Try %d", rid, c)
Debugf("Not attempting reconnect for solicited route, already connected. Try %d", rid, c)
return
} else {
Debug("Attempting reconnect for solicited route", c)
Debugf("Attempting reconnect for solicited route", c)
go srv.reConnectToRoute(c.route.url)
}
}
}
func (c *client) Errorf(format string, v ...interface{}) {
format = fmt.Sprintf("%s - %s", c, format)
Errorf(format, v...)
}

View File

@@ -3,7 +3,6 @@
package server
import (
"fmt"
"sync"
"sync/atomic"
)
@@ -16,11 +15,11 @@ var log = struct {
}{}
type Logger interface {
Notice(format string, v ...interface{})
Fatal(format string, v ...interface{})
Error(format string, v ...interface{})
Debug(format string, v ...interface{})
Trace(format string, v ...interface{})
Noticef(format string, v ...interface{})
Fatalf(format string, v ...interface{})
Errorf(format string, v ...interface{})
Debugf(format string, v ...interface{})
Tracef(format string, v ...interface{})
}
func (s *Server) SetLogger(logger Logger, d, t bool) {
@@ -37,41 +36,41 @@ func (s *Server) SetLogger(logger Logger, d, t bool) {
log.logger = logger
}
func Notice(format string, v ...interface{}) {
func Noticef(format string, v ...interface{}) {
executeLogCall(func(logger Logger, format string, v ...interface{}) {
logger.Notice(format, v...)
logger.Noticef(format, v...)
}, format, v...)
}
func Error(format string, v ...interface{}) {
func Errorf(format string, v ...interface{}) {
executeLogCall(func(logger Logger, format string, v ...interface{}) {
logger.Error(format, v...)
logger.Errorf(format, v...)
}, format, v...)
}
func Fatal(format string, v ...interface{}) {
func Fatalf(format string, v ...interface{}) {
executeLogCall(func(logger Logger, format string, v ...interface{}) {
logger.Fatal(format, v...)
logger.Fatalf(format, v...)
}, format, v...)
}
func Debug(format string, v ...interface{}) {
func Debugf(format string, v ...interface{}) {
if debug == 0 {
return
}
executeLogCall(func(logger Logger, format string, v ...interface{}) {
logger.Debug(format, v...)
logger.Debugf(format, v...)
}, format, v...)
}
func Trace(format string, v ...interface{}) {
func Tracef(format string, v ...interface{}) {
if trace == 0 {
return
}
executeLogCall(func(logger Logger, format string, v ...interface{}) {
logger.Trace(format, v...)
logger.Tracef(format, v...)
}, format, v...)
}
@@ -81,14 +80,5 @@ func executeLogCall(f func(logger Logger, format string, v ...interface{}), form
if log.logger == nil {
return
}
argc := len(args)
if argc != 0 {
if client, ok := args[argc-1].(*client); ok {
args = args[:argc-1]
format = fmt.Sprintf("%s - %s", client, format)
}
}
f(log.logger, format, args...)
}

View File

@@ -24,8 +24,8 @@ func TestSetLogger(t *testing.T) {
type DummyLogger struct{}
func (l *DummyLogger) Notice(format string, v ...interface{}) {}
func (l *DummyLogger) Error(format string, v ...interface{}) {}
func (l *DummyLogger) Fatal(format string, v ...interface{}) {}
func (l *DummyLogger) Debug(format string, v ...interface{}) {}
func (l *DummyLogger) Trace(format string, v ...interface{}) {}
func (l *DummyLogger) Noticef(format string, v ...interface{}) {}
func (l *DummyLogger) Errorf(format string, v ...interface{}) {}
func (l *DummyLogger) Fatalf(format string, v ...interface{}) {}
func (l *DummyLogger) Debugf(format string, v ...interface{}) {}
func (l *DummyLogger) Tracef(format string, v ...interface{}) {}

View File

@@ -88,7 +88,7 @@ func (s *Server) HandleConnz(w http.ResponseWriter, r *http.Request) {
b, err := json.MarshalIndent(c, "", " ")
if err != nil {
Error("Error marshalling response to /connz request: %v", err)
Errorf("Error marshalling response to /connz request: %v", err)
}
w.Write(b)
}
@@ -114,7 +114,7 @@ func (s *Server) HandleSubsz(w http.ResponseWriter, r *http.Request) {
b, err := json.MarshalIndent(st, "", " ")
if err != nil {
Error("Error marshalling response to /subscriptionsz request: %v", err)
Errorf("Error marshalling response to /subscriptionsz request: %v", err)
}
w.Write(b)
}
@@ -161,7 +161,7 @@ func (s *Server) HandleVarz(w http.ResponseWriter, r *http.Request) {
b, err := json.MarshalIndent(v, "", " ")
if err != nil {
Error("Error marshalling response to /varz request: %v", err)
Errorf("Error marshalling response to /varz request: %v", err)
}
w.Write(b)
}

View File

@@ -225,7 +225,7 @@ func RemoveSelfReference(clusterPort int, routes []*url.URL) ([]*url.URL, error)
}
if cport == port && isIpInList(selfIPs, getUrlIp(host)) {
Notice("Self referencing IP found: ", r)
Noticef("Self referencing IP found: ", r)
continue
}
cleanRoutes = append(cleanRoutes, r)
@@ -256,7 +256,7 @@ func getUrlIp(ipStr string) []net.IP {
hostAddr, err := net.LookupHost(ipStr)
if err != nil {
Error("Error looking up host with route hostname: ", err)
Errorf("Error looking up host with route hostname: %v", err)
return ipList
}
for _, addr := range hostAddr {
@@ -273,7 +273,7 @@ func getInterfaceIPs() []net.IP {
interfaceAddr, err := net.InterfaceAddrs()
if err != nil {
Error("Error getting self referencing address: ", err)
Errorf("Error getting self referencing address: %v", err)
return localIPs
}
@@ -282,7 +282,7 @@ func getInterfaceIPs() []net.IP {
if net.ParseIP(interfaceIP.String()) != nil {
localIPs = append(localIPs, interfaceIP)
} else {
Error("Error parsing self referencing address: ", err)
Errorf("Error parsing self referencing address: %v", err)
}
}
return localIPs

View File

@@ -46,7 +46,7 @@ func (c *client) sendConnect() {
}
b, err := json.Marshal(cinfo)
if err != nil {
Error("Error marshalling CONNECT to route: %v\n", err)
Errorf("Error marshalling CONNECT to route: %v\n", err)
c.closeConnection()
}
c.bw.WriteString(fmt.Sprintf(conProto, b))
@@ -79,7 +79,7 @@ func (s *Server) sendLocalSubsToRoute(route *client) {
route.bw.Write(b.Bytes())
route.bw.Flush()
Debug("Route sent local subscriptions", route)
Debugf("Route sent local subscriptions", route)
}
func (s *Server) createRoute(conn net.Conn, rURL *url.URL) *client {
@@ -93,12 +93,12 @@ func (s *Server) createRoute(conn net.Conn, rURL *url.URL) *client {
// Initialize
c.initClient()
Debug("Route connection created", c)
Debugf("Route connection created", c)
// Queue Connect proto if we solicited the connection.
if didSolicit {
r.url = rURL
Debug("Route connect msg sent", c)
Debugf("Route connect msg sent", c)
c.sendConnect()
}
@@ -234,10 +234,10 @@ func (s *Server) broadcastUnSubscribe(sub *subscription) {
func (s *Server) routeAcceptLoop(ch chan struct{}) {
hp := fmt.Sprintf("%s:%d", s.opts.ClusterHost, s.opts.ClusterPort)
Notice("Listening for route connections on %s", hp)
Noticef("Listening for route connections on %s", hp)
l, e := net.Listen("tcp", hp)
if e != nil {
Fatal("Error listening on router port: %d - %v", s.opts.Port, e)
Fatalf("Error listening on router port: %d - %v", s.opts.Port, e)
return
}
@@ -255,7 +255,7 @@ func (s *Server) routeAcceptLoop(ch chan struct{}) {
conn, err := l.Accept()
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
Debug("Temporary Route Accept Error(%v), sleeping %dms",
Debugf("Temporary Route Accept Errorf(%v), sleeping %dms",
ne, tmpDelay/time.Millisecond)
time.Sleep(tmpDelay)
tmpDelay *= 2
@@ -263,14 +263,14 @@ func (s *Server) routeAcceptLoop(ch chan struct{}) {
tmpDelay = ACCEPT_MAX_SLEEP
}
} else if s.isRunning() {
Notice("Accept error: %v", err)
Noticef("Accept error: %v", err)
}
continue
}
tmpDelay = ACCEPT_MIN_SLEEP
s.createRoute(conn, nil)
}
Debug("Router accept loop exiting..")
Debugf("Router accept loop exiting..")
s.done <- true
}
@@ -294,7 +294,7 @@ func (s *Server) StartRouting() {
// Generate the info json
b, err := json.Marshal(info)
if err != nil {
Fatal("Error marshalling Route INFO JSON: %+v\n", err)
Fatalf("Error marshalling Route INFO JSON: %+v\n", err)
}
s.routeInfoJSON = []byte(fmt.Sprintf("INFO %s %s", b, CR_LF))
@@ -314,10 +314,10 @@ func (s *Server) reConnectToRoute(rUrl *url.URL) {
func (s *Server) connectToRoute(rUrl *url.URL) {
for s.isRunning() {
Debug("Trying to connect to route on %s", rUrl.Host)
Debugf("Trying to connect to route on %s", rUrl.Host)
conn, err := net.DialTimeout("tcp", rUrl.Host, DEFAULT_ROUTE_DIAL)
if err != nil {
Debug("Error trying to connect to route: %v", err)
Debugf("Error trying to connect to route: %v", err)
select {
case <-s.rcQuit:
return

View File

@@ -111,7 +111,7 @@ func New(opts *Options) *Server {
// Generate the info json
b, err := json.Marshal(s.info)
if err != nil {
Fatal("Error marshalling INFO JSON: %+v\n", err)
Fatalf("Error marshalling INFO JSON: %+v\n", err)
}
s.infoJSON = []byte(fmt.Sprintf("INFO %s %s", b, CR_LF))
@@ -140,9 +140,9 @@ func (s *Server) handleSignals() {
signal.Notify(c, os.Interrupt)
go func() {
for sig := range c {
Debug("Trapped Signal; %v", sig)
Debugf("Trapped Signal; %v", sig)
// FIXME, trip running?
Notice("Server Exiting..")
Noticef("Server Exiting..")
os.Exit(0)
}
}()
@@ -166,7 +166,7 @@ func (s *Server) logPid() {
// Start up the server, this will block.
// Start via a Go routine if needed.
func (s *Server) Start() {
Notice("Starting gnatsd version %s", VERSION)
Noticef("Starting gnatsd version %s", VERSION)
s.running = true
// Log the pid to a file
@@ -261,14 +261,14 @@ func (s *Server) Shutdown() {
// AcceptLoop is exported for easier testing.
func (s *Server) AcceptLoop() {
hp := fmt.Sprintf("%s:%d", s.opts.Host, s.opts.Port)
Notice("Listening for client connections on %s", hp)
Noticef("Listening for client connections on %s", hp)
l, e := net.Listen("tcp", hp)
if e != nil {
Fatal("Error listening on port: %d - %v", s.opts.Port, e)
Fatalf("Error listening on port: %d - %v", s.opts.Port, e)
return
}
Notice("gnatsd is ready")
Noticef("gnatsd is ready")
// Setup state that can enable shutdown
s.mu.Lock()
@@ -278,12 +278,12 @@ func (s *Server) AcceptLoop() {
// Write resolved port back to options.
_, port, err := net.SplitHostPort(l.Addr().String())
if err != nil {
Fatal("Error parsing server address (%s): %s", l.Addr().String(), e)
Fatalf("Error parsing server address (%s): %s", l.Addr().String(), e)
return
}
portNum, err := strconv.Atoi(port)
if err != nil {
Fatal("Error parsing server address (%s): %s", l.Addr().String(), e)
Fatalf("Error parsing server address (%s): %s", l.Addr().String(), e)
return
}
s.opts.Port = portNum
@@ -294,7 +294,7 @@ func (s *Server) AcceptLoop() {
conn, err := l.Accept()
if err != nil {
if ne, ok := err.(net.Error); ok && ne.Temporary() {
Debug("Temporary Client Accept Error(%v), sleeping %dms",
Debugf("Temporary Client Accept Error(%v), sleeping %dms",
ne, tmpDelay/time.Millisecond)
time.Sleep(tmpDelay)
tmpDelay *= 2
@@ -302,39 +302,39 @@ func (s *Server) AcceptLoop() {
tmpDelay = ACCEPT_MAX_SLEEP
}
} else if s.isRunning() {
Notice("Accept error: %v", err)
Noticef("Accept error: %v", err)
}
continue
}
tmpDelay = ACCEPT_MIN_SLEEP
s.createClient(conn)
}
Notice("Server Exiting..")
Noticef("Server Exiting..")
s.done <- true
}
// StartProfiler is called to enable dynamic profiling.
func (s *Server) StartProfiler() {
Notice("Starting profiling on http port %d", s.opts.ProfPort)
Noticef("Starting profiling on http port %d", s.opts.ProfPort)
hp := fmt.Sprintf("%s:%d", s.opts.Host, s.opts.ProfPort)
go func() {
err := http.ListenAndServe(hp, nil)
if err != nil {
Fatal("error starting monitor server: %s", err)
Fatalf("error starting monitor server: %s", err)
}
}()
}
// StartHTTPMonitoring will enable the HTTP monitoring port.
func (s *Server) StartHTTPMonitoring() {
Notice("Starting http monitor on port %d", s.opts.HTTPPort)
Noticef("Starting http monitor on port %d", s.opts.HTTPPort)
hp := fmt.Sprintf("%s:%d", s.opts.Host, s.opts.HTTPPort)
l, err := net.Listen("tcp", hp)
if err != nil {
Fatal("Can't listen to the monitor port: %v", err)
Fatalf("Can't listen to the monitor port: %v", err)
}
mux := http.NewServeMux()
@@ -374,7 +374,7 @@ func (s *Server) createClient(conn net.Conn) *client {
// Initialize
c.initClient()
Debug("Client connection created", c)
Debugf("Client connection created", c)
// Send our information.
s.sendInfo(c)