1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-02 11:30:35 +02:00

Logging in subscribe and publish command

This commit is contained in:
Philipp Heckel 2022-06-02 11:59:22 -04:00
parent 5cc0b194d3
commit e12995e218
10 changed files with 67 additions and 48 deletions
server

View file

@ -1,7 +1,6 @@
package server
import (
"encoding/json"
"fmt"
"github.com/emersion/go-smtp"
"net/http"
@ -59,14 +58,3 @@ func logHTTPPrefix(v *visitor, r *http.Request) string {
func logSMTPPrefix(state *smtp.ConnectionState) string {
return fmt.Sprintf("%s/%s SMTP", state.Hostname, state.RemoteAddr.String())
}
func maybeMarshalJSON(v interface{}) string {
messageJSON, err := json.MarshalIndent(v, "", " ")
if err != nil {
return "<cannot serialize>"
}
if len(messageJSON) > 5000 {
return string(messageJSON)[:5000]
}
return string(messageJSON)
}