rabbah commented on a change in pull request #2650: Apply standard scala 
formatting.
URL: 
https://github.com/apache/incubator-openwhisk/pull/2650#discussion_r136238680
 
 

 ##########
 File path: common/scala/src/main/scala/whisk/common/TransactionId.scala
 ##########
 @@ -39,90 +39,107 @@ import whisk.core.entity.InstanceId
  * metadata is stored indirectly in the referenced meta object.
  */
 case class TransactionId private (meta: TransactionMetadata) extends AnyVal {
-    def id = meta.id
-    override def toString = {
-        if (meta.id > 0) s"#tid_${meta.id}"
-        else if (meta.id < 0) s"#sid_${-meta.id}"
-        else "??"
-    }
-
-    /**
-     * Method to count events.
-     *
-     * @param from Reference, where the method was called from.
-     * @param marker A LogMarkerToken. They are defined in 
<code>LoggingMarkers</code>.
-     * @param message An additional message that is written into the log, 
together with the other information.
-     * @param logLevel The Loglevel, the message should have. Default is 
<code>InfoLevel</code>.
-     */
-    def mark(from: AnyRef, marker: LogMarkerToken, message: String = "", 
logLevel: LogLevel = InfoLevel)(implicit logging: Logging) = {
-        logging.emit(logLevel, this, from, createMessageWithMarker(message, 
LogMarker(marker, deltaToStart)))
-    }
-
-    /**
-     * Method to start taking time of an action in the code. It returns a 
<code>StartMarker</code> which has to be
-     * passed into the <code>finished</code>-method.
-     *
-     * @param from Reference, where the method was called from.
-     * @param marker A LogMarkerToken. They are defined in 
<code>LoggingMarkers</code>.
-     * @param message An additional message that is written into the log, 
together with the other information.
-     * @param logLevel The Loglevel, the message should have. Default is 
<code>InfoLevel</code>.
-     *
-     * @return startMarker that has to be passed to the finished or failed 
method to calculate the time difference.
-     */
-    def started(from: AnyRef, marker: LogMarkerToken, message: String = "", 
logLevel: LogLevel = InfoLevel)(implicit logging: Logging): StartMarker = {
-        logging.emit(logLevel, this, from, createMessageWithMarker(message, 
LogMarker(marker, deltaToStart)))
-        StartMarker(Instant.now, marker)
-    }
-
-    /**
-     * Method to stop taking time of an action in the code. The time the 
method used will be written into a log message.
-     *
-     * @param from Reference, where the method was called from.
-     * @param startMarker <code>StartMarker</code> returned by a 
<code>starting</code> method.
-     * @param message An additional message that is written into the log, 
together with the other information.
-     * @param logLevel The Loglevel, the message should have. Default is 
<code>InfoLevel</code>.
-     * @param endTime Manually set the timestamp of the end. By default it is 
NOW.
-     */
-    def finished(from: AnyRef, startMarker: StartMarker, message: String = "", 
logLevel: LogLevel = InfoLevel, endTime: Instant = 
Instant.now(Clock.systemUTC))(implicit logging: Logging) = {
-        val endMarker = LogMarkerToken(startMarker.startMarker.component, 
startMarker.startMarker.action, LoggingMarkers.finish)
-        logging.emit(logLevel, this, from, createMessageWithMarker(message, 
LogMarker(endMarker, deltaToStart, Some(deltaToMarker(startMarker, endTime)))))
-    }
-
-    /**
-     * Method to stop taking time of an action in the code that failed. The 
time the method used will be written into a log message.
-     *
-     * @param from Reference, where the method was called from.
-     * @param startMarker <code>StartMarker</code> returned by a 
<code>starting</code> method.
-     * @param message An additional message that is written into the log, 
together with the other information.
-     * @param logLevel The <code>LogLevel</code> the message should have. 
Default is <code>WarningLevel</code>.
-     */
-    def failed(from: AnyRef, startMarker: StartMarker, message: String = "", 
logLevel: LogLevel = WarningLevel)(implicit logging: Logging) = {
-        val endMarker = LogMarkerToken(startMarker.startMarker.component, 
startMarker.startMarker.action, LoggingMarkers.error)
-        logging.emit(logLevel, this, from, createMessageWithMarker(message, 
LogMarker(endMarker, deltaToStart, Some(deltaToMarker(startMarker)))))
-    }
-
-    /**
-     * Calculates the time between now and the beginning of the transaction.
-     */
-    def deltaToStart = Duration.between(meta.start, 
Instant.now(Clock.systemUTC)).toMillis
-
-    /**
-     * Calculates the time between now and the startMarker that was returned 
by <code>starting</code>.
-     *
-     * @param startMarker <code>StartMarker</code> returned by a 
<code>starting</code> method.
-     * @param endTime Manually set the endtime. By default it is NOW.
-     */
-    def deltaToMarker(startMarker: StartMarker, endTime: Instant = 
Instant.now(Clock.systemUTC)) = Duration.between(startMarker.start, 
endTime).toMillis
-
-    /**
-     * Formats log message to include marker.
-     *
-     * @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(" ")
-    }
+  def id = meta.id
+  override def toString = {
+    if (meta.id > 0) s"#tid_${meta.id}"
+    else if (meta.id < 0) s"#sid_${-meta.id}"
+    else "??"
+  }
+
+  /**
+   * Method to count events.
+   *
+   * @param from Reference, where the method was called from.
+   * @param marker A LogMarkerToken. They are defined in 
<code>LoggingMarkers</code>.
+   * @param message An additional message that is written into the log, 
together with the other information.
+   * @param logLevel The Loglevel, the message should have. Default is 
<code>InfoLevel</code>.
+   */
+  def mark(from: AnyRef, marker: LogMarkerToken, message: String = "", 
logLevel: LogLevel = InfoLevel)(
+      implicit logging: Logging) = {
+    logging.emit(logLevel, this, from, createMessageWithMarker(message, 
LogMarker(marker, deltaToStart)))
+  }
+
+  /**
+   * Method to start taking time of an action in the code. It returns a 
<code>StartMarker</code> which has to be
+   * passed into the <code>finished</code>-method.
+   *
+   * @param from Reference, where the method was called from.
+   * @param marker A LogMarkerToken. They are defined in 
<code>LoggingMarkers</code>.
+   * @param message An additional message that is written into the log, 
together with the other information.
+   * @param logLevel The Loglevel, the message should have. Default is 
<code>InfoLevel</code>.
+   *
+   * @return startMarker that has to be passed to the finished or failed 
method to calculate the time difference.
+   */
+  def started(from: AnyRef, marker: LogMarkerToken, message: String = "", 
logLevel: LogLevel = InfoLevel)(
+      implicit logging: Logging): StartMarker = {
+    logging.emit(logLevel, this, from, createMessageWithMarker(message, 
LogMarker(marker, deltaToStart)))
+    StartMarker(Instant.now, marker)
+  }
+
+  /**
+   * Method to stop taking time of an action in the code. The time the method 
used will be written into a log message.
+   *
+   * @param from Reference, where the method was called from.
+   * @param startMarker <code>StartMarker</code> returned by a 
<code>starting</code> method.
+   * @param message An additional message that is written into the log, 
together with the other information.
+   * @param logLevel The Loglevel, the message should have. Default is 
<code>InfoLevel</code>.
+   * @param endTime Manually set the timestamp of the end. By default it is 
NOW.
+   */
+  def finished(from: AnyRef,
+               startMarker: StartMarker,
+               message: String = "",
+               logLevel: LogLevel = InfoLevel,
+               endTime: Instant = Instant.now(Clock.systemUTC))(implicit 
logging: Logging) = {
+    val endMarker =
+      LogMarkerToken(startMarker.startMarker.component, 
startMarker.startMarker.action, LoggingMarkers.finish)
+    logging.emit(
+      logLevel,
+      this,
+      from,
+      createMessageWithMarker(message, LogMarker(endMarker, deltaToStart, 
Some(deltaToMarker(startMarker, endTime)))))
+  }
+
+  /**
+   * Method to stop taking time of an action in the code that failed. The time 
the method used will be written into a log message.
+   *
+   * @param from Reference, where the method was called from.
+   * @param startMarker <code>StartMarker</code> returned by a 
<code>starting</code> method.
+   * @param message An additional message that is written into the log, 
together with the other information.
+   * @param logLevel The <code>LogLevel</code> the message should have. 
Default is <code>WarningLevel</code>.
+   */
+  def failed(from: AnyRef, startMarker: StartMarker, message: String = "", 
logLevel: LogLevel = WarningLevel)(
+      implicit logging: Logging) = {
+    val endMarker =
+      LogMarkerToken(startMarker.startMarker.component, 
startMarker.startMarker.action, LoggingMarkers.error)
+    logging.emit(logLevel,
+                 this,
+                 from,
+                 createMessageWithMarker(message, LogMarker(endMarker, 
deltaToStart, Some(deltaToMarker(startMarker)))))
+  }
+
+  /**
+   * Calculates the time between now and the beginning of the transaction.
+   */
+  def deltaToStart = Duration.between(meta.start, 
Instant.now(Clock.systemUTC)).toMillis
+
+  /**
+   * Calculates the time between now and the startMarker that was returned by 
<code>starting</code>.
+   *
+   * @param startMarker <code>StartMarker</code> returned by a 
<code>starting</code> method.
+   * @param endTime Manually set the endtime. By default it is NOW.
+   */
+  def deltaToMarker(startMarker: StartMarker, endTime: Instant = 
Instant.now(Clock.systemUTC)) =
+    Duration.between(startMarker.start, endTime).toMillis
 
 Review comment:
   comparing 140 to 131, i like 140 better for example.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to