No need to include trailing newline in log messages.

This commit is contained in:
Joachim Bauch 2021-06-04 16:42:17 +02:00
parent 9a921a6572
commit 2f4414561e
No known key found for this signature in database
GPG Key ID: 77C1D22D53E15F02
10 changed files with 45 additions and 45 deletions

View File

@ -299,20 +299,20 @@ func (b *BackendClient) PerformJSONRequest(ctx context.Context, u *url.URL, requ
pool, err := b.getPool(u)
if err != nil {
log.Printf("Could not get client pool for host %s: %s\n", u.Host, err)
log.Printf("Could not get client pool for host %s: %s", u.Host, err)
return err
}
c, err := pool.Get(ctx)
if err != nil {
log.Printf("Could not get client for host %s: %s\n", u.Host, err)
log.Printf("Could not get client for host %s: %s", u.Host, err)
return err
}
defer pool.Put(c)
data, err := json.Marshal(request)
if err != nil {
log.Printf("Could not marshal request %+v: %s\n", request, err)
log.Printf("Could not marshal request %+v: %s", request, err)
return err
}
@ -335,20 +335,20 @@ func (b *BackendClient) PerformJSONRequest(ctx context.Context, u *url.URL, requ
resp, err := performRequestWithRedirects(ctx, c, req, data)
if err != nil {
log.Printf("Could not send request %s to %s: %s\n", string(data), u.String(), err)
log.Printf("Could not send request %s to %s: %s", string(data), u.String(), err)
return err
}
defer resp.Body.Close()
ct := resp.Header.Get("Content-Type")
if !strings.HasPrefix(ct, "application/json") {
log.Printf("Received unsupported content-type from %s: %s (%s)\n", u.String(), ct, resp.Status)
log.Printf("Received unsupported content-type from %s: %s (%s)", u.String(), ct, resp.Status)
return fmt.Errorf("unsupported_content_type")
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Printf("Could not read response body from %s: %s\n", u.String(), err)
log.Printf("Could not read response body from %s: %s", u.String(), err)
return err
}

View File

@ -160,7 +160,7 @@ func NewBackendConfiguration(config *goconf.ConfigFile) (*BackendConfiguration,
if len(hosts) > 1 {
log.Println("WARNING: Using deprecated backend configuration. Please migrate the \"allowed\" setting to the new \"backends\" configuration.")
}
log.Printf("Allowed backend hostnames: %s\n", hosts)
log.Printf("Allowed backend hostnames: %s", hosts)
if sessionLimit > 0 {
log.Printf("Allow a maximum of %d sessions", sessionLimit)
}

View File

@ -250,7 +250,7 @@ func (b *BackendServer) parseRequestBody(f func(http.ResponseWriter, *http.Reque
}
ct := r.Header.Get("Content-Type")
if !strings.HasPrefix(ct, "application/json") {
log.Printf("Received unsupported content-type: %s\n", ct)
log.Printf("Received unsupported content-type: %s", ct)
http.Error(w, "Unsupported Content-Type", http.StatusBadRequest)
return
}
@ -556,7 +556,7 @@ func (b *BackendServer) roomHandler(w http.ResponseWriter, r *http.Request, body
var request BackendServerRoomRequest
if err := json.Unmarshal(body, &request); err != nil {
log.Printf("Error decoding body %s: %s\n", string(body), err)
log.Printf("Error decoding body %s: %s", string(body), err)
http.Error(w, "Could not read body", http.StatusBadRequest)
return
}
@ -589,7 +589,7 @@ func (b *BackendServer) roomHandler(w http.ResponseWriter, r *http.Request, body
}
if err != nil {
log.Printf("Error processing %s for room %s: %s\n", string(body), roomid, err)
log.Printf("Error processing %s for room %s: %s", string(body), roomid, err)
http.Error(w, "Error while processing", http.StatusInternalServerError)
return
}

View File

@ -107,7 +107,7 @@ func (s *Stats) Log() {
sentMessages := totalSentMessages - s.resetSentMessages
totalRecvMessages := atomic.AddUint64(&s.numRecvMessages, 0)
recvMessages := totalRecvMessages - s.resetRecvMessages
log.Printf("Stats: sent=%d (%d/sec), recv=%d (%d/sec), delta=%d\n",
log.Printf("Stats: sent=%d (%d/sec), recv=%d (%d/sec), delta=%d",
totalSentMessages, sentMessages/perSec,
totalRecvMessages, recvMessages/perSec,
totalSentMessages-totalRecvMessages)
@ -207,13 +207,13 @@ func (c *SignalingClient) processMessage(message *signaling.ServerMessage) {
case "message":
c.processMessageMessage(message)
case "bye":
log.Printf("Received bye: %+v\n", message.Bye)
log.Printf("Received bye: %+v", message.Bye)
c.Close()
case "error":
log.Printf("Received error: %+v\n", message.Error)
log.Printf("Received error: %+v", message.Error)
c.Close()
default:
log.Printf("Unsupported message type: %+v\n", *message)
log.Printf("Unsupported message type: %+v", *message)
}
}
@ -239,7 +239,7 @@ func (c *SignalingClient) processHelloMessage(message *signaling.ServerMessage)
c.privateSessionId = message.Hello.ResumeId
c.publicSessionId = c.privateToPublicSessionId(c.privateSessionId)
c.userId = message.Hello.UserId
log.Printf("Registered as %s (userid %s)\n", c.privateSessionId, c.userId)
log.Printf("Registered as %s (userid %s)", c.privateSessionId, c.userId)
c.ready_wg.Done()
}
@ -259,7 +259,7 @@ func (c *SignalingClient) processMessageMessage(message *signaling.ServerMessage
now := time.Now()
duration := now.Sub(msg.Now)
if duration > messageReportDuration {
log.Printf("Message took %s\n", duration)
log.Printf("Message took %s", duration)
}
}
@ -286,7 +286,7 @@ func (c *SignalingClient) readPump() {
websocket.CloseNormalClosure,
websocket.CloseGoingAway,
websocket.CloseNoStatusReceived) {
log.Printf("Error: %v\n", err)
log.Printf("Error: %v", err)
}
break
}
@ -308,7 +308,7 @@ func (c *SignalingClient) readPump() {
var message signaling.ServerMessage
if err := message.UnmarshalJSON(decodeBuffer.Bytes()); err != nil {
log.Printf("Error: %v\n", err)
log.Printf("Error: %v", err)
break
}
@ -526,7 +526,7 @@ func main() {
case 32:
case 64:
default:
log.Printf("WARNING: The sessions hash key should be 32 or 64 bytes but is %d bytes\n", len(hashKey))
log.Printf("WARNING: The sessions hash key should be 32 or 64 bytes but is %d bytes", len(hashKey))
}
blockKey, _ := config.GetString("sessions", "blockkey")
@ -544,7 +544,7 @@ func main() {
cpus := runtime.NumCPU()
runtime.GOMAXPROCS(cpus)
log.Printf("Using a maximum of %d CPUs\n", cpus)
log.Printf("Using a maximum of %d CPUs", cpus)
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)
@ -578,16 +578,16 @@ func main() {
urls = append(urls, u)
urlstrings = append(urlstrings, u.String())
}
log.Printf("Connecting to %s\n", urlstrings)
log.Printf("Connecting to %s", urlstrings)
clients := make([]*SignalingClient, 0)
stats := &Stats{}
if *maxClients < 2 {
log.Fatalf("Need at least 2 clients, got %d\n", *maxClients)
log.Fatalf("Need at least 2 clients, got %d", *maxClients)
}
log.Printf("Starting %d clients\n", *maxClients)
log.Printf("Starting %d clients", *maxClients)
var done_wg sync.WaitGroup
var ready_wg sync.WaitGroup

View File

@ -399,7 +399,7 @@ func (s *ClientSession) SubscribeRoomNats(n NatsClient, roomid string, roomSessi
return err
}
}
log.Printf("Session %s joined room %s with room session id %s\n", s.PublicId(), roomid, roomSessionId)
log.Printf("Session %s joined room %s with room session id %s", s.PublicId(), roomid, roomSessionId)
s.roomSessionId = roomSessionId
return nil
}
@ -413,7 +413,7 @@ func (s *ClientSession) LeaveCall() {
return
}
log.Printf("Session %s left call %s\n", s.PublicId(), room.Id())
log.Printf("Session %s left call %s", s.PublicId(), room.Id())
s.releaseMcuObjects()
}
@ -779,7 +779,7 @@ func (s *ClientSession) processNatsMessage(msg *NatsMessage) *ServerMessage {
switch msg.Type {
case "message":
if msg.Message == nil {
log.Printf("Received NATS message without payload: %+v\n", msg)
log.Printf("Received NATS message without payload: %+v", msg)
return nil
}
@ -820,7 +820,7 @@ func (s *ClientSession) processNatsMessage(msg *NatsMessage) *ServerMessage {
return msg.Message
default:
log.Printf("Received NATS message with unsupported type %s: %+v\n", msg.Type, msg)
log.Printf("Received NATS message with unsupported type %s: %+v", msg.Type, msg)
return nil
}
}

2
hub.go
View File

@ -1289,7 +1289,7 @@ func (h *Hub) processMessageMsg(client *Client, message *ClientMessage) {
return
}
log.Printf("Closing screen publisher for %s\n", session.PublicId())
log.Printf("Closing screen publisher for %s", session.PublicId())
ctx, cancel := context.WithTimeout(context.Background(), h.mcuTimeout)
defer cancel()
publisher.Close(ctx)

View File

@ -73,14 +73,14 @@ func convertIntValue(value interface{}) (uint64, error) {
switch t := value.(type) {
case float64:
if t < 0 {
return 0, fmt.Errorf("Unsupported float64 number: %+v\n", t)
return 0, fmt.Errorf("Unsupported float64 number: %+v", t)
}
return uint64(t), nil
case uint64:
return t, nil
case int64:
if t < 0 {
return 0, fmt.Errorf("Unsupported int64 number: %+v\n", t)
return 0, fmt.Errorf("Unsupported int64 number: %+v", t)
}
return uint64(t), nil
case json.Number:
@ -88,11 +88,11 @@ func convertIntValue(value interface{}) (uint64, error) {
if err != nil {
return 0, err
} else if r < 0 {
return 0, fmt.Errorf("Unsupported JSON number: %+v\n", t)
return 0, fmt.Errorf("Unsupported JSON number: %+v", t)
}
return uint64(r), nil
default:
return 0, fmt.Errorf("Unknown number type: %+v\n", t)
return 0, fmt.Errorf("Unknown number type: %+v", t)
}
}
@ -104,7 +104,7 @@ func getPluginIntValue(data janus.PluginData, pluginName string, key string) uin
result, err := convertIntValue(val)
if err != nil {
log.Printf("Invalid value %+v for %s: %s\n", val, key, err)
log.Printf("Invalid value %+v for %s: %s", val, key, err)
result = 0
}
return result
@ -267,9 +267,9 @@ func (m *mcuJanus) scheduleReconnect(err error) {
defer m.mu.Unlock()
m.reconnectTimer.Reset(m.reconnectInterval)
if err == nil {
log.Printf("Connection to Janus gateway was interrupted, reconnecting in %s\n", m.reconnectInterval)
log.Printf("Connection to Janus gateway was interrupted, reconnecting in %s", m.reconnectInterval)
} else {
log.Printf("Reconnect to Janus gateway failed (%s), reconnecting in %s\n", err, m.reconnectInterval)
log.Printf("Reconnect to Janus gateway failed (%s), reconnecting in %s", err, m.reconnectInterval)
}
m.reconnectInterval = m.reconnectInterval * 2
@ -290,11 +290,11 @@ func (m *mcuJanus) Start() error {
return err
}
log.Printf("Connected to %s %s by %s\n", info.Name, info.VersionString, info.Author)
log.Printf("Connected to %s %s by %s", info.Name, info.VersionString, info.Author)
if plugin, found := info.Plugins[pluginVideoRoom]; !found {
return fmt.Errorf("Plugin %s is not supported", pluginVideoRoom)
} else {
log.Printf("Found %s %s by %s\n", plugin.Name, plugin.VersionString, plugin.Author)
log.Printf("Found %s %s by %s", plugin.Name, plugin.VersionString, plugin.Author)
}
if !info.DataChannels {
@ -743,7 +743,7 @@ func (p *mcuJanusPublisher) NotifyReconnected() {
ctx := context.TODO()
handle, session, roomId, err := p.mcu.getOrCreatePublisherHandle(ctx, p.id, p.streamType, p.bitrate)
if err != nil {
log.Printf("Could not reconnect publisher %s: %s\n", p.id, err)
log.Printf("Could not reconnect publisher %s: %s", p.id, err)
// TODO(jojo): Retry
return
}
@ -949,7 +949,7 @@ func (p *mcuJanusSubscriber) NotifyReconnected() {
handle, pub, err := p.mcu.getOrCreateSubscriberHandle(ctx, p.publisher, p.streamType)
if err != nil {
// TODO(jojo): Retry?
log.Printf("Could not reconnect subscriber for publisher %s: %s\n", p.publisher, err)
log.Printf("Could not reconnect subscriber for publisher %s: %s", p.publisher, err)
p.Close(context.Background())
return
}

View File

@ -113,7 +113,7 @@ func NewNatsClient(url string) (NatsClient, error) {
client.nc, err = nats.Connect(url)
}
log.Printf("Connection established to %s (%s)\n", client.nc.ConnectedUrl(), client.nc.ConnectedServerId())
log.Printf("Connection established to %s (%s)", client.nc.ConnectedUrl(), client.nc.ConnectedServerId())
// All communication will be JSON based.
client.conn, _ = nats.NewEncodedConn(client.nc, nats.JSON_ENCODER)
@ -133,7 +133,7 @@ func (c *natsClient) onDisconnected(conn *nats.Conn) {
}
func (c *natsClient) onReconnected(conn *nats.Conn) {
log.Printf("NATS client reconnected to %s (%s)\n", conn.ConnectedUrl(), conn.ConnectedServerId())
log.Printf("NATS client reconnected to %s (%s)", conn.ConnectedUrl(), conn.ConnectedServerId())
}
func (c *natsClient) Subscribe(subject string, ch chan *nats.Msg) (NatsSubscription, error) {

View File

@ -76,7 +76,7 @@ func main() {
cpus := runtime.NumCPU()
runtime.GOMAXPROCS(cpus)
log.Printf("Using a maximum of %d CPUs\n", cpus)
log.Printf("Using a maximum of %d CPUs", cpus)
r := mux.NewRouter()

View File

@ -111,7 +111,7 @@ func main() {
if err := runtimepprof.StartCPUProfile(f); err != nil {
log.Fatalf("Error writing CPU profile to %s: %s", *cpuprofile, err)
}
log.Printf("Writing CPU profile to %s ...\n", *cpuprofile)
log.Printf("Writing CPU profile to %s ...", *cpuprofile)
defer runtimepprof.StopCPUProfile()
}
@ -122,7 +122,7 @@ func main() {
}
defer func() {
log.Printf("Writing Memory profile to %s ...\n", *memprofile)
log.Printf("Writing Memory profile to %s ...", *memprofile)
runtime.GC()
if err := runtimepprof.WriteHeapProfile(f); err != nil {
log.Printf("Error writing Memory profile to %s: %s", *memprofile, err)
@ -139,7 +139,7 @@ func main() {
cpus := runtime.NumCPU()
runtime.GOMAXPROCS(cpus)
log.Printf("Using a maximum of %d CPUs\n", cpus)
log.Printf("Using a maximum of %d CPUs", cpus)
natsUrl, _ := config.GetString("nats", "url")
if natsUrl == "" {