Simplify warewulfd logging

- Collapse SEND and RECV logs into INFO.
- Add /etc/default/warewulfd

Closes #725

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2024-05-24 17:10:45 -06:00
parent 983214f253
commit d33ca6ff53
7 changed files with 8 additions and 29 deletions

View File

@@ -53,7 +53,7 @@ func DaemonInitLogging() error {
wwlog.SetLogLevel(level)
}
} else {
wwlog.SetLogLevel(wwlog.SERV)
wwlog.SetLogLevel(wwlog.INFO)
}
conf := warewulfconf.Get()

View File

@@ -48,7 +48,7 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
return
}
wwlog.Recv("hwaddr: %s, ipaddr: %s, stage: %s", rinfo.hwaddr, req.RemoteAddr, rinfo.stage)
wwlog.Info("request from hwaddr:%s ipaddr:%s | stage:%s", rinfo.hwaddr, req.RemoteAddr, rinfo.stage)
if (rinfo.stage == "runtime" || len(rinfo.overlay) > 0) && conf.Warewulf.Secure {
if rinfo.remoteport >= 1024 {
@@ -276,7 +276,7 @@ func ProvisionSend(w http.ResponseWriter, req *http.Request) {
wwlog.ErrorExc(err, "")
}
wwlog.Send("%15s: %s", remoteNode.Id(), stage_file)
wwlog.Info("send %s -> %s", stage_file, remoteNode.Id())
} else {
if rinfo.compress == "gz" {

View File

@@ -39,7 +39,7 @@ func sendFile(
stat.ModTime(),
fd)
wwlog.Send("%15s: %s", sendto, filename)
wwlog.Info("send %s -> %s", filename, sendto)
req.Body.Close()
return nil
}

View File

@@ -37,8 +37,6 @@ var (
SECWARN = SetLevelName(31, "SECWARN")
WARN = SetLevelName(30, "WARN")
ERROUT = SetLevelName(29, "ERROUT")
SEND = SetLevelName(27, "SEND")
RECV = SetLevelName(26, "RECV")
SERV = SetLevelName(25, "SERV")
OUT = SetLevelName(22, "OUT")
SECINFO = SetLevelName(21, "SECINFO")
@@ -206,7 +204,7 @@ func LogCaller(level int, skip int, err error, message string, a ...interface{})
}
message = logFormatter(logLevel, &rec)
if level == INFO || level == RECV || level == SEND || level == OUT {
if level == INFO || level == OUT {
fmt.Fprint(logOut, message)
} else {
fmt.Fprint(logErr, message)
@@ -271,14 +269,6 @@ func Serv(message string, a ...interface{}) {
LogCaller(SERV, 1, nil, message, a...)
}
func Recv(message string, a ...interface{}) {
LogCaller(RECV, 1, nil, message, a...)
}
func Send(message string, a ...interface{}) {
LogCaller(SEND, 1, nil, message, a...)
}
func Warn(message string, a ...interface{}) {
LogCaller(WARN, 1, nil, message, a...)
}

View File

@@ -126,20 +126,6 @@ func Test_Log(t *testing.T) {
expect: "SERV : Serv\n",
exactMatch: true,
},
{
name: "Recv",
msgTypeFunc: Recv,
message: "Recv",
expect: "RECV : Recv\n",
exactMatch: true,
},
{
name: "Send",
msgTypeFunc: Send,
message: "Send",
expect: "SEND : Send\n",
exactMatch: true,
},
{
name: "Warn",
msgTypeFunc: Warn,