cleaned up and fixed broken error logging

This commit is contained in:
jboner 2009-11-24 07:58:14 +01:00
parent bd2942094e
commit 794750f7fa
5 changed files with 19 additions and 24 deletions

View file

@ -738,7 +738,7 @@ trait Actor extends Logging with TransactionManagement {
else dispatch(messageHandle)
} catch {
case e =>
log.error(e, e.getMessage) // for logging the exception to log file
log.error(e, "Could not invoke actor [%s]", this)
throw e
}
}
@ -755,7 +755,7 @@ trait Actor extends Logging with TransactionManagement {
else throw new IllegalArgumentException("No handler matching message [" + message + "] in " + toString)
} catch {
case e =>
log.error(e, e.getMessage)
log.error(e, "Could not invoke actor [%s]", this)
// FIXME to fix supervisor restart of remote actor for oneway calls, inject a supervisor proxy that can send notification back to client
if (_supervisor.isDefined) _supervisor.get ! Exit(this, e)
if (senderFuture.isDefined) senderFuture.get.completeWithException(this, e)
@ -795,7 +795,7 @@ trait Actor extends Logging with TransactionManagement {
} else proceed
} catch {
case e =>
log.error(e, e.getMessage)
log.error(e, "Could not invoke actor [%s]", this)
if (senderFuture.isDefined) senderFuture.get.completeWithException(this, e)
clearTransaction // need to clear currentTransaction before call to supervisor
// FIXME to fix supervisor restart of remote actor for oneway calls, inject a supervisor proxy that can send notification back to client

View file

@ -366,7 +366,7 @@ object AMQP {
reconnect(delay)
case Failure(cause) =>
log.error(cause, "")
log.error(cause, "Error in AMQP consumer")
throw cause
case Stop =>
@ -421,8 +421,8 @@ object AMQP {
} catch {
case cause =>
log.error(
"Delivery of message to MessageConsumerListener [%s] failed due to [%s]",
listener.toString(exchangeName), cause.toString)
cause, "Delivery of message to MessageConsumerListener [%s] failed",
listener.toString(exchangeName))
consumer ! Failure(cause) // pass on and re-throw exception in consumer actor to trigger restart and reconnect
}
}

View file

@ -94,7 +94,7 @@ object Kernel extends Logging {
val DEPLOY = HOME.get + "/deploy"
val DEPLOY_DIR = new File(DEPLOY)
if (!DEPLOY_DIR.exists) {
log.error("Could not find a deploy directory at [" + DEPLOY + "]")
log.error("Could not find a deploy directory at [%s]", DEPLOY)
System.exit(-1)
}
val toDeploy = for (f <- DEPLOY_DIR.listFiles().toArray.toList.asInstanceOf[List[File]]) yield f.toURL

View file

@ -91,7 +91,7 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging {
case r if r.isInstanceOf[Response] =>
throw new WebApplicationException(r.asInstanceOf[Response])
case x => {
log.error("Authenticator replied with unexpected result: ", x);
log.error("Authenticator replied with unexpected result [%s]", x);
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR)
}
}
@ -100,7 +100,9 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging {
}
}
lazy val authenticatorFQN = Config.config.getString("akka.rest.authenticator").getOrElse(throw new IllegalStateException("akka.rest.authenticator"))
lazy val authenticatorFQN =
Config.config.getString("akka.rest.authenticator")
.getOrElse(throw new IllegalStateException("akka.rest.authenticator"))
/**
* Currently we always take the first, since there usually should be at most one authentication actor, but a round-robin

View file

@ -4,11 +4,8 @@
package se.scalablesolutions.akka.util
import java.util.logging.Level
import net.lag.configgy.Config
import net.lag.logging.Logger
import java.util.Date
import java.io.StringWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
@ -20,11 +17,7 @@ import java.net.UnknownHostException;
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
trait Logging {
@transient var log = {
val log = Logger.get(this.getClass.getName)
//0log.setLevel(Level.ALL)
log
}
@transient @volatile var log = Logger.get(this.getClass.getName)
}
/**
@ -50,14 +43,14 @@ class LoggableException extends Exception with Logging {
def logException = synchronized {
if (!isLogged) {
originalException match {
case Some(e) => log.error("Logged Exception [%s] %s", uniqueId, getStackTrace(e))
case None => log.error("Logged Exception [%s] %s", uniqueId, getStackTrace(this))
case Some(e) => log.error("Logged Exception [%s] %s", uniqueId, getStackTraceAsString(e))
case None => log.error("Logged Exception [%s] %s", uniqueId, getStackTraceAsString(this))
}
isLogged = true
}
}
}
def getExceptionID: String = {
private def getExceptionID: String = {
val hostname: String = try {
InetAddress.getLocalHost.getHostName
} catch {
@ -68,7 +61,7 @@ class LoggableException extends Exception with Logging {
hostname + "_" + System.currentTimeMillis
}
def getStackTrace(exception: Throwable): String = {
private def getStackTraceAsString(exception: Throwable): String = {
val sw = new StringWriter
val pw = new PrintWriter(sw)
exception.printStackTrace(pw)