Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit c19073e

Browse files
committed
Added PluginLogMessages to the api, encapsulating a message and logging timestamp. Updated framework and rest interface.
1 parent 7b6b702 commit c19073e

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

src/main/scala/org/codeoverflow/chatoverflow/framework/manager/PluginManagerImpl.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package org.codeoverflow.chatoverflow.framework.manager
33
import java.util
44

55
import org.codeoverflow.chatoverflow.WithLogger
6-
import org.codeoverflow.chatoverflow.api.plugin.PluginManager
6+
import org.codeoverflow.chatoverflow.api.plugin.{PluginLogMessage, PluginManager}
77

88
import scala.collection.JavaConverters._
99
import scala.collection.mutable.ListBuffer
@@ -15,15 +15,15 @@ import scala.collection.mutable.ListBuffer
1515
*/
1616
class PluginManagerImpl(pluginInstanceName: String, logOutputOnConsole: Boolean) extends PluginManager with WithLogger {
1717

18-
private val logMessages = new ListBuffer[String]
18+
private val logMessages = new ListBuffer[PluginLogMessage]
1919

2020
/**
2121
* Prints a log message on the console and saves the message for later inspection.
2222
*
2323
* @param message the message to show
2424
*/
2525
override def log(message: String): Unit = {
26-
logMessages += message
26+
logMessages += new PluginLogMessage(message)
2727

2828
if (logOutputOnConsole) {
2929
logger info s"[$pluginInstanceName] $message"
@@ -35,5 +35,5 @@ class PluginManagerImpl(pluginInstanceName: String, logOutputOnConsole: Boolean)
3535
*
3636
* @return a list of log messages
3737
*/
38-
override def getLogMessages: util.List[String] = logMessages.toList.asJava
38+
override def getLogMessages: util.List[PluginLogMessage] = logMessages.toList.asJava
3939
}

src/main/scala/org/codeoverflow/chatoverflow/framework/manager/PluginManagerStub.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.codeoverflow.chatoverflow.framework.manager
22

33
import java.util
44

5-
import org.codeoverflow.chatoverflow.api.plugin.PluginManager
5+
import org.codeoverflow.chatoverflow.api.plugin.{PluginLogMessage, PluginManager}
66

77
/**
88
* This plugin manager stub does not provide any useful functionality and should only be used for
@@ -23,7 +23,7 @@ class PluginManagerStub extends PluginManager {
2323
*
2424
* @return a list of log messages
2525
*/
26-
override def getLogMessages: util.List[String] = {
27-
new util.ArrayList[String]()
26+
override def getLogMessages: util.List[PluginLogMessage] = {
27+
new util.ArrayList[PluginLogMessage]()
2828
}
2929
}

src/main/scala/org/codeoverflow/chatoverflow/ui/web/rest/DTOs.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ object DTOs {
4343

4444
case class Password(password: String)
4545

46+
case class PluginLogMessageDTO(message: String, timestamp: String)
47+
4648
}

src/main/scala/org/codeoverflow/chatoverflow/ui/web/rest/plugin/PluginInstanceController.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ class PluginInstanceController(implicit val swagger: Swagger) extends JsonServle
201201
val startIndex = if (params.isDefinedAt("startIndex")) Some(params("startIndex")) else None
202202
val pluginInstance = chatOverflow.pluginInstanceRegistry.getPluginInstance(instanceName)
203203
val logMessages = pluginInstance.get.getPluginManager.getLogMessages
204+
.asScala.map(logMessage => PluginLogMessageDTO(logMessage.getMessage, logMessage.getTimestamp.toString))
204205

205206
val index = startIndex.getOrElse("0")
206207
val msg = logMessages.toArray.drop(Integer.parseInt(index))

src/main/scala/org/codeoverflow/chatoverflow/ui/web/rest/plugin/PluginInstanceControllerDefinition.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ trait PluginInstanceControllerDefinition extends SwaggerSupport with TagSupport
5353
parameter pathParam[String]("instanceName").description("The name of the plugin instance.")
5454
parameter pathParam[String]("requirementID").description("The unique id of the requirement."))
5555
val getLog: OperationBuilder =
56-
(apiOperation[List[String]]("getLog")
56+
(apiOperation[List[PluginLogMessageDTO]]("getLog")
5757
summary "Shows the log of a plugin instance."
5858
description "Shows all (or the newest) log messages of a specified plugin instance."
5959
tags controllerTag

0 commit comments

Comments
 (0)