Skip to content

Commit

Permalink
Fixes #2603 by defining log templates and binding variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Nov 10, 2015
1 parent ae8e8ab commit b8060eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Expand Up @@ -2,16 +2,15 @@ package mesosphere.marathon.event.http

import akka.actor._
import akka.pattern.ask
import mesosphere.marathon.api.v2.json.Formats._
import mesosphere.marathon.event._
import mesosphere.marathon.event.http.SubscribersKeeperActor.GetSubscribers
import play.api.libs.json.{ JsValue, Json }
import spray.client.pipelining.{ sendReceive, _ }
import spray.http.{ HttpRequest, HttpResponse }
import spray.client.pipelining.{sendReceive, _}
import spray.http.{HttpRequest, HttpResponse}
import spray.httpx.PlayJsonSupport
import mesosphere.marathon.api.v2.json.Formats._

import scala.concurrent.Future
import scala.util.{ Failure, Success }
import scala.util.{Failure, Success}

class HttpEventActor(val subscribersKeeper: ActorRef) extends Actor with ActorLogging with PlayJsonSupport {

Expand Down Expand Up @@ -45,10 +44,9 @@ class HttpEventActor(val subscribersKeeper: ActorRef) extends Actor with ActorLo
response.onComplete {
case Success(res) =>
if (res.status.isFailure)
log.warning(s"Failed to post $event to $urlString")

log.warning(s"Post {} to {} resulted in error response {}", event, urlString, res.status)
case Failure(t) =>
log.warning(s"Failed to post $event to $urlString", t)
log.warning("Failed to post {} to {} reason: {}", event, urlString, t)
}
}
}
Expand Down
Expand Up @@ -76,11 +76,11 @@ class HttpEventStreamHandleActor(
//Do not act any longer on any event.
context.become(Actor.emptyBehavior)
case _ =>
log.warning(s"Could not send message to $handle", ex)
log.warning("Could not send message to {} reason: {}", handle, ex)
}

private[this] def dropEvent(event: MarathonEvent): Unit = {
log.warning(s"Ignore event $event for handle $handle (slow consumer)")
log.warning("Ignore event {} for handle {} (slow consumer)", event, handle)
}
}

Expand Down
Expand Up @@ -20,7 +20,7 @@ class SubscribersKeeperActor(val store: EntityStore[EventSubscribers]) extends A
val subscription: Future[MarathonSubscriptionEvent] =
addResult.map { subscribers =>
if (subscribers.urls.contains(callbackUrl))
log.info("Callback [%s] subscribed." format callbackUrl)
log.info("Callback {} subscribed.", callbackUrl)
event
}

Expand All @@ -32,7 +32,7 @@ class SubscribersKeeperActor(val store: EntityStore[EventSubscribers]) extends A
val subscription: Future[MarathonSubscriptionEvent] =
removeResult.map { subscribers =>
if (!subscribers.urls.contains(callbackUrl))
log.info("Callback [%s] unsubscribed." format callbackUrl)
log.info("Callback {} unsubscribed.", callbackUrl)
event
}

Expand All @@ -48,7 +48,7 @@ class SubscribersKeeperActor(val store: EntityStore[EventSubscribers]) extends A
store.modify(Subscribers) { deserialize =>
val existingSubscribers = deserialize()
if (existingSubscribers.urls.contains(callbackUrl)) {
log.info("Existing callback [%s] resubscribed." format callbackUrl)
log.info("Existing callback {} resubscribed.", callbackUrl)
existingSubscribers
}
else EventSubscribers(existingSubscribers.urls + callbackUrl)
Expand All @@ -62,7 +62,7 @@ class SubscribersKeeperActor(val store: EntityStore[EventSubscribers]) extends A
EventSubscribers(existingSubscribers.urls - callbackUrl)

else {
log.warning("Attempted to unsubscribe nonexistent callback [%s]." format callbackUrl)
log.warning("Attempted to unsubscribe nonexistent callback {}", callbackUrl)
existingSubscribers
}
}
Expand Down

0 comments on commit b8060eb

Please sign in to comment.