diff --git a/dhcp/dhcp.go b/dhcp/dhcp.go index 1391822..4eddd14 100644 --- a/dhcp/dhcp.go +++ b/dhcp/dhcp.go @@ -46,7 +46,7 @@ type dhcpDiscover struct { func DiscoverDHCP() { err := sendDHCPDiscovery() if err != nil { - logging.Logger().Error(fmt.Sprintf("Discovery: DHCP Matcher %v", err)) + logging.Logger().Errorf("Discovery: DHCP Matcher %v", err) return } recvDHCPOffer() @@ -101,23 +101,23 @@ func recvDHCPOffer() { Port: 68, }) if err != nil { - logging.Logger().Error(fmt.Sprintf("Discovery: DHCP Matcher %v", err)) + logging.Logger().Errorf("Discovery: DHCP Matcher %v", err) return } err = socket.SetDeadline(time.Now().Add(3 * time.Second)) if err != nil { - logging.Logger().Error(fmt.Sprintf("Discovery: DHCP Matcher %v", err)) + logging.Logger().Errorf("Discovery: DHCP Matcher %v", err) return } buf := make([]byte, 4096) n, _, err := socket.ReadFromUDP(buf) if err != nil { - logging.Logger().Error(fmt.Sprintf("Discovery: DHCP Matcher %v", err)) + logging.Logger().Errorf("Discovery: DHCP Matcher %v", err) return } if n <= 0 { - logging.Logger().Error(fmt.Sprintf("Discovery: DHCP Matcher has no DHCP offer.")) + logging.Logger().Errorf("Discovery: DHCP Matcher has no DHCP offer.") return } @@ -126,11 +126,11 @@ func recvDHCPOffer() { reader := new(bytes.Buffer) reader.Write(buf) if err := binary.Read(reader, binary.BigEndian, &offer); err != nil { - logging.Logger().Error(fmt.Sprintf("Discovery: DHCP Matcher %v", err)) + logging.Logger().Errorf("Discovery: DHCP Matcher %v", err) return } if offer.MagicCookie != MAGIC_COOKIE { - logging.Logger().Error(fmt.Sprintf("Discovery: DHCP Matcher is not a DHCP packet.")) + logging.Logger().Errorf("Discovery: DHCP Matcher is not a DHCP packet.") return } @@ -143,12 +143,12 @@ func recvDHCPOffer() { if v == OPT_CODE_SUBNET_MASK && r.Next(1)[0] == 4 { ipStr := byteToIpString(r.Next(4)) - logging.Logger().Info(fmt.Sprintf("Discovery: DHCP Matcher SUBNET MASK: %s", ipStr)) + logging.Logger().Infof("Discovery: DHCP Matcher SUBNET MASK: %s", ipStr) } if v == OPT_CODE_ROUTER && r.Next(1)[0] == 4 { ipStr := byteToIpString(r.Next(4)) - logging.Logger().Info(fmt.Sprintf("Discovery: DHCP Matcher ROUTER: %s", ipStr)) + logging.Logger().Infof("Discovery: DHCP Matcher ROUTER: %s", ipStr) } if v == OPT_CODE_DNS { @@ -161,12 +161,12 @@ func recvDHCPOffer() { ipStr = byteToIpString(r.Next(4)) dns = append(dns, ipStr) } - logging.Logger().Info(fmt.Sprintf("Discovery: DHCP Matcher DNS: %s", dns)) + logging.Logger().Infof("Discovery: DHCP Matcher DNS: %s", dns) } if v == OPT_CODE_SERVER_IDENTIFIER && r.Next(1)[0] == 4 { ipStr := byteToIpString(r.Next(4)) - logging.Logger().Info(fmt.Sprintf("Discovery: DHCP Matcher DHCP SERVER: %s", ipStr)) + logging.Logger().Infof("Discovery: DHCP Matcher DHCP SERVER: %s", ipStr) } } logging.Logger().Sync() diff --git a/ftp/ftp.go b/ftp/ftp.go index b1aa2fb..97dd0bc 100644 --- a/ftp/ftp.go +++ b/ftp/ftp.go @@ -56,7 +56,7 @@ func (ftp *FTPMatcher) Match(info cnsm.MatchInfo, index int, packet *cnsm.Packet result := false if packet == nil || packet.Buffer == nil || packet.Len == 0 { - logging.Logger().Error(fmt.Sprintf("Discovery: FTP Matcher Packet nil")) + logging.Logger().Errorf("Discovery: FTP Matcher Packet nil") return result } @@ -105,7 +105,7 @@ func (ftp *FTPMatcher) Match(info cnsm.MatchInfo, index int, packet *cnsm.Packet if isfs && err == nil { ftp.isFtps = isfs } else if err != nil { - logging.Logger().Warn(fmt.Sprintf("Discovery: FTP Matcher Check Error %v", err)) + logging.Logger().Warnf("Discovery: FTP Matcher Check Error %v", err) } } diff --git a/ftp/ftps.go b/ftp/ftps.go index a10f5aa..afc67d6 100644 --- a/ftp/ftps.go +++ b/ftp/ftps.go @@ -40,12 +40,12 @@ func (fs *FTPS) quit() (err error) { func (fs *FTPS) cmd(expects string, cmd string) (line string, err error) { if err = fs.send(cmd); err != nil { - logging.Logger().Error(fmt.Sprintf("Discovery: FTPS Matcher cmd send error %v", err)) + logging.Logger().Errorf("Discovery: FTPS Matcher cmd send error %v", err) return "", err } if line, err = fs.receive(); err != nil { - logging.Logger().Error(fmt.Sprintf("Discovery: FTPS Matcher cmd receive error %v", err)) + logging.Logger().Errorf("Discovery: FTPS Matcher cmd receive error %v", err) return line, err } @@ -132,7 +132,7 @@ func (fs *FTPS) NewFTPSConnect(addr string) (*FTPS, error) { var conn net.Conn if conn, err = net.Dial("tcp", addr); err != nil { - logging.Logger().Error(fmt.Sprintf("Discovery: FTPS Matcher Socket Fail %v", err)) + logging.Logger().Errorf("Discovery: FTPS Matcher Socket Fail %v", err) return nil, err }