This is an automated email from the ASF dual-hosted git repository.

cbickel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 52f41d4  Make logging hot paths lighter. (#2784)
52f41d4 is described below

commit 52f41d4bab4a4c9045004e89b4708fe06d458396
Author: Markus Thömmes <markusthoem...@me.com>
AuthorDate: Thu Sep 21 15:47:47 2017 +0200

    Make logging hot paths lighter. (#2784)
    
    Logging is **the** hotspot in our application today. This takes a first 
stab at making the overhead a bit smaller by respecting the set log-level as 
early as currently possible and not do any extranous throwaway computation.
    
    It also reduces a bit of unnecessary boxing for the sake of just trying to 
keep a single space out of the message.
---
 common/scala/src/main/scala/whisk/common/Logging.scala       | 11 +++--------
 common/scala/src/main/scala/whisk/common/TransactionId.scala |  4 +---
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/common/scala/src/main/scala/whisk/common/Logging.scala 
b/common/scala/src/main/scala/whisk/common/Logging.scala
index 92c921a..b86a72d 100644
--- a/common/scala/src/main/scala/whisk/common/Logging.scala
+++ b/common/scala/src/main/scala/whisk/common/Logging.scala
@@ -85,15 +85,10 @@ trait Logging {
  */
 class AkkaLogging(loggingAdapter: LoggingAdapter) extends Logging {
   def emit(loglevel: LogLevel, id: TransactionId, from: AnyRef, message: 
String) = {
-    val name = if (from.isInstanceOf[String]) from else 
Logging.getCleanSimpleClassName(from.getClass)
-
-    val logMessage = Seq(message).collect {
-      case msg if msg.nonEmpty =>
-        msg.split('\n').map(_.trim).mkString(" ")
+    if (loggingAdapter.isEnabled(loglevel)) {
+      val name = if (from.isInstanceOf[String]) from else 
Logging.getCleanSimpleClassName(from.getClass)
+      loggingAdapter.log(loglevel, s"[$id] [$name] $message")
     }
-
-    val parts = Seq(s"[$id]") ++ Seq(s"[$name]") ++ logMessage
-    loggingAdapter.log(loglevel, parts.mkString(" "))
   }
 }
 
diff --git a/common/scala/src/main/scala/whisk/common/TransactionId.scala 
b/common/scala/src/main/scala/whisk/common/TransactionId.scala
index 0023b8b..1e04ce6 100644
--- a/common/scala/src/main/scala/whisk/common/TransactionId.scala
+++ b/common/scala/src/main/scala/whisk/common/TransactionId.scala
@@ -137,9 +137,7 @@ case class TransactionId private (meta: 
TransactionMetadata) extends AnyVal {
    * @param message: The log message without the marker
    * @param marker: The marker to add to the message
    */
-  private def createMessageWithMarker(message: String, marker: LogMarker): 
String = {
-    (Option(message).filter(_.trim.nonEmpty) ++ Some(marker)).mkString(" ")
-  }
+  private def createMessageWithMarker(message: String, marker: LogMarker): 
String = s"$message $marker"
 }
 
 /**

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].

Reply via email to