diff --git a/devserver/src/main/scala/io/adamnfish/pokerdot/DevServer.scala b/devserver/src/main/scala/io/adamnfish/pokerdot/DevServer.scala index f12a4b6..73aed29 100644 --- a/devserver/src/main/scala/io/adamnfish/pokerdot/DevServer.scala +++ b/devserver/src/main/scala/io/adamnfish/pokerdot/DevServer.scala @@ -30,12 +30,12 @@ object DevServer extends LazyLogging { seed.toLong } .getOrElse(0L) - logger.info(s"[INFO] initial seed: $initialSeed") + logger.info(s"initial seed: $initialSeed") val rng = new DevRng(initialSeed) val messagePrinter: Direction => (String, String) => Unit = if (args.contains("--debug")) { - logger.info("[INFO] debug mode - connection events and messages will be printed") + logger.info("debug mode - connection events and messages will be printed") logMessage } else { noOpMessage @@ -69,23 +69,23 @@ object DevServer extends LazyLogging { } } match { case Exit.Success(operation) => - logger.info(s"[INFO] completed $operation") + logger.info(s"completed $operation") case Exit.Failure(cause) => cause.failures.foreach { fs => - logger.error(s"[ERROR] error: ${fs.logString}") + logger.error(s"error: ${fs.logString}") fs.exception.foreach { e => - logger.error(s"[ERROR] exception: ${e.printStackTrace()}") + logger.error(s"exception: ${e.printStackTrace()}") } } cause.defects.foreach { err => - logger.error(s"[ERROR] Fatal error: ${err.toString}") + logger.error(s"Fatal error: ${err.getMessage}", err) } } } }) Runtime.getRuntime.addShutdownHook(new Thread(() => { - logger.info("[INFO] Stopping...") + logger.info("Stopping...") app.stop() })) } diff --git a/lambda/src/main/scala/io/adamnfish/pokerdot/AwsMessaging.scala b/lambda/src/main/scala/io/adamnfish/pokerdot/AwsMessaging.scala index 8514a7f..21a836e 100644 --- a/lambda/src/main/scala/io/adamnfish/pokerdot/AwsMessaging.scala +++ b/lambda/src/main/scala/io/adamnfish/pokerdot/AwsMessaging.scala @@ -20,7 +20,7 @@ class AwsMessaging(client: ApiGatewayManagementApiClient) extends Messaging with } private def send(playerAddress: PlayerAddress, message: String): Attempt[Unit] = { - logger.debug(s"Message (${playerAddress.address}): $message") + logger.debug(s"Message {${playerAddress.address}}: $message") val request = PostToConnectionRequest.builder .connectionId(playerAddress.address) .data(SdkBytes.fromByteArray(message.getBytes("UTF-8"))) diff --git a/lambda/src/main/scala/io/adamnfish/pokerdot/Lambda.scala b/lambda/src/main/scala/io/adamnfish/pokerdot/Lambda.scala index c280098..4c8b44f 100644 --- a/lambda/src/main/scala/io/adamnfish/pokerdot/Lambda.scala +++ b/lambda/src/main/scala/io/adamnfish/pokerdot/Lambda.scala @@ -21,7 +21,7 @@ import scala.util.Properties class Lambda extends LazyLogging { // initialise AWS clients at start time - val appContextBuilder: (PlayerAddress, AwsContext) => AppContext = { + val appContextBuilder: PlayerAddress => AppContext = { (for { // AWS ASK configuration regionStr <- Properties.envOrNone("REGION") @@ -50,7 +50,7 @@ class Lambda extends LazyLogging { .build() db = new DynamoDbDatabase(dynamoDbClient, gamesTableName, playersTableName) rng = new RandomRng - } yield { (playerAddress: PlayerAddress, awsContext: AwsContext) => + } yield { (playerAddress: PlayerAddress) => val messaging = new AwsMessaging(apiGatewayManagementClient) AppContext(playerAddress, db, messaging, Clock, rng) }).fold( @@ -74,7 +74,7 @@ class Lambda extends LazyLogging { // ignore this for now case "$default" => val playerAddress = PlayerAddress(event.getRequestContext.getConnectionId) - val appContext = appContextBuilder(playerAddress, awsContext) + val appContext = appContextBuilder(playerAddress) Unsafe.unsafe { implicit unsafe => Runtime.default.unsafe.run( @@ -82,16 +82,16 @@ class Lambda extends LazyLogging { ) } match { case Exit.Success(operation) => - logger.info(s"[INFO] completed $operation") + logger.info(s"completed $operation") case Exit.Failure(cause) => cause.failures.foreach { fs => - logger.error(s"[ERROR] error: ${fs.logString}") + logger.error(s"error: ${fs.logString}") fs.exception.foreach { e => - logger.error(s"[ERROR] exception: ${e.printStackTrace()}") + logger.error(s"exception: ${e.printStackTrace()}") } } cause.defects.foreach { err => - logger.error(s"[ERROR] Fatal error: ${err.toString}") + logger.error(s"Fatal error: ${err.getMessage}", err) } } } @@ -103,4 +103,3 @@ class Lambda extends LazyLogging { response } } -