Rename log events

This commit is contained in:
Eugene Yokota 2017-01-25 23:15:31 -05:00
parent f76e3aa2bb
commit 1320c96953
8 changed files with 29 additions and 29 deletions

View File

@ -4,7 +4,7 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.util package sbt.internal.util
final class ChannelLogEntry private ( final class StringEvent private (
val level: String, val level: String,
val message: String, val message: String,
channelName: Option[String], channelName: Option[String],
@ -13,39 +13,39 @@ final class ChannelLogEntry private (
override def equals(o: Any): Boolean = o match { override def equals(o: Any): Boolean = o match {
case x: ChannelLogEntry => (this.level == x.level) && (this.message == x.message) && (this.channelName == x.channelName) && (this.execId == x.execId) case x: StringEvent => (this.level == x.level) && (this.message == x.message) && (this.channelName == x.channelName) && (this.execId == x.execId)
case _ => false case _ => false
} }
override def hashCode: Int = { override def hashCode: Int = {
37 * (37 * (37 * (37 * (17 + level.##) + message.##) + channelName.##) + execId.##) 37 * (37 * (37 * (37 * (17 + level.##) + message.##) + channelName.##) + execId.##)
} }
override def toString: String = { override def toString: String = {
"ChannelLogEntry(" + level + ", " + message + ", " + channelName + ", " + execId + ")" "StringEvent(" + level + ", " + message + ", " + channelName + ", " + execId + ")"
} }
protected[this] def copy(level: String = level, message: String = message, channelName: Option[String] = channelName, execId: Option[String] = execId): ChannelLogEntry = { protected[this] def copy(level: String = level, message: String = message, channelName: Option[String] = channelName, execId: Option[String] = execId): StringEvent = {
new ChannelLogEntry(level, message, channelName, execId) new StringEvent(level, message, channelName, execId)
} }
def withLevel(level: String): ChannelLogEntry = { def withLevel(level: String): StringEvent = {
copy(level = level) copy(level = level)
} }
def withMessage(message: String): ChannelLogEntry = { def withMessage(message: String): StringEvent = {
copy(message = message) copy(message = message)
} }
def withChannelName(channelName: Option[String]): ChannelLogEntry = { def withChannelName(channelName: Option[String]): StringEvent = {
copy(channelName = channelName) copy(channelName = channelName)
} }
def withChannelName(channelName: String): ChannelLogEntry = { def withChannelName(channelName: String): StringEvent = {
copy(channelName = Option(channelName)) copy(channelName = Option(channelName))
} }
def withExecId(execId: Option[String]): ChannelLogEntry = { def withExecId(execId: Option[String]): StringEvent = {
copy(execId = execId) copy(execId = execId)
} }
def withExecId(execId: String): ChannelLogEntry = { def withExecId(execId: String): StringEvent = {
copy(execId = Option(execId)) copy(execId = Option(execId))
} }
} }
object ChannelLogEntry { object StringEvent {
def apply(level: String, message: String, channelName: Option[String], execId: Option[String]): ChannelLogEntry = new ChannelLogEntry(level, message, channelName, execId) def apply(level: String, message: String, channelName: Option[String], execId: Option[String]): StringEvent = new StringEvent(level, message, channelName, execId)
def apply(level: String, message: String, channelName: String, execId: String): ChannelLogEntry = new ChannelLogEntry(level, message, Option(channelName), Option(execId)) def apply(level: String, message: String, channelName: String, execId: String): StringEvent = new StringEvent(level, message, Option(channelName), Option(execId))
} }

View File

@ -5,6 +5,6 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.util.codec package sbt.internal.util.codec
import _root_.sjsonnew.{ deserializationError, serializationError, Builder, JsonFormat, Unbuilder } import _root_.sjsonnew.{ deserializationError, serializationError, Builder, JsonFormat, Unbuilder }
trait AbstractEntryFormats { self: sjsonnew.BasicJsonProtocol with sbt.internal.util.codec.ChannelLogEntryFormats => trait AbstractEntryFormats { self: sjsonnew.BasicJsonProtocol with sbt.internal.util.codec.StringEventFormats =>
implicit lazy val AbstractEntryFormat: JsonFormat[sbt.internal.util.AbstractEntry] = flatUnionFormat1[sbt.internal.util.AbstractEntry, sbt.internal.util.ChannelLogEntry]("type") implicit lazy val AbstractEntryFormat: JsonFormat[sbt.internal.util.AbstractEntry] = flatUnionFormat1[sbt.internal.util.AbstractEntry, sbt.internal.util.StringEvent]("type")
} }

View File

@ -5,6 +5,6 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.util.codec package sbt.internal.util.codec
trait JsonProtocol extends sjsonnew.BasicJsonProtocol trait JsonProtocol extends sjsonnew.BasicJsonProtocol
with sbt.internal.util.codec.ChannelLogEntryFormats with sbt.internal.util.codec.StringEventFormats
with sbt.internal.util.codec.AbstractEntryFormats with sbt.internal.util.codec.AbstractEntryFormats
object JsonProtocol extends JsonProtocol object JsonProtocol extends JsonProtocol

View File

@ -5,9 +5,9 @@
// DO NOT EDIT MANUALLY // DO NOT EDIT MANUALLY
package sbt.internal.util.codec package sbt.internal.util.codec
import _root_.sjsonnew.{ deserializationError, serializationError, Builder, JsonFormat, Unbuilder } import _root_.sjsonnew.{ deserializationError, serializationError, Builder, JsonFormat, Unbuilder }
trait ChannelLogEntryFormats { self: sjsonnew.BasicJsonProtocol => trait StringEventFormats { self: sjsonnew.BasicJsonProtocol =>
implicit lazy val ChannelLogEntryFormat: JsonFormat[sbt.internal.util.ChannelLogEntry] = new JsonFormat[sbt.internal.util.ChannelLogEntry] { implicit lazy val StringEventFormat: JsonFormat[sbt.internal.util.StringEvent] = new JsonFormat[sbt.internal.util.StringEvent] {
override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.util.ChannelLogEntry = { override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.internal.util.StringEvent = {
jsOpt match { jsOpt match {
case Some(js) => case Some(js) =>
unbuilder.beginObject(js) unbuilder.beginObject(js)
@ -16,12 +16,12 @@ implicit lazy val ChannelLogEntryFormat: JsonFormat[sbt.internal.util.ChannelLog
val channelName = unbuilder.readField[Option[String]]("channelName") val channelName = unbuilder.readField[Option[String]]("channelName")
val execId = unbuilder.readField[Option[String]]("execId") val execId = unbuilder.readField[Option[String]]("execId")
unbuilder.endObject() unbuilder.endObject()
sbt.internal.util.ChannelLogEntry(level, message, channelName, execId) sbt.internal.util.StringEvent(level, message, channelName, execId)
case None => case None =>
deserializationError("Expected JsObject but found None") deserializationError("Expected JsObject but found None")
} }
} }
override def write[J](obj: sbt.internal.util.ChannelLogEntry, builder: Builder[J]): Unit = { override def write[J](obj: sbt.internal.util.StringEvent, builder: Builder[J]): Unit = {
builder.beginObject() builder.beginObject()
builder.addField("level", obj.level) builder.addField("level", obj.level)
builder.addField("message", obj.message) builder.addField("message", obj.message)

View File

@ -8,7 +8,7 @@ interface AbstractEntry {
execId: String execId: String
} }
type ChannelLogEntry implements sbt.internal.util.AbstractEntry { type StringEvent implements sbt.internal.util.AbstractEntry {
level: String! level: String!
message: String! message: String!
channelName: String channelName: String

View File

@ -260,9 +260,9 @@ class ConsoleAppender private[ConsoleAppender] (
} }
def objectToString(o: AnyRef): String = def objectToString(o: AnyRef): String =
o match { o match {
case x: ChannelLogEntry => x.message case x: StringEvent => x.message
case x: ObjectLogEntry[_] => x.message.toString case x: ObjectEvent[_] => x.message.toString
case _ => o.toString case _ => o.toString
} }
def messageColor(level: Level.Value) = RESET def messageColor(level: Level.Value) = RESET

View File

@ -19,7 +19,7 @@ class ManagedLogger(
{ {
xlogger.log( xlogger.log(
ConsoleAppender.toXLevel(level), ConsoleAppender.toXLevel(level),
new ObjectMessage(ChannelLogEntry(level.toString, message, channelName, execId)) new ObjectMessage(StringEvent(level.toString, message, channelName, execId))
) )
} }
override def success(message: => String): Unit = xlogger.info(message) override def success(message: => String): Unit = xlogger.info(message)
@ -33,7 +33,7 @@ class ManagedLogger(
val v: A = event val v: A = event
val clazz: Class[A] = v.getClass.asInstanceOf[Class[A]] val clazz: Class[A] = v.getClass.asInstanceOf[Class[A]]
val ev = LogExchange.getOrElseUpdateJsonCodec(clazz, implicitly[JsonFormat[A]]) val ev = LogExchange.getOrElseUpdateJsonCodec(clazz, implicitly[JsonFormat[A]])
val entry: ObjectLogEntry[A] = new ObjectLogEntry(level, v, channelName, execId, ev, clazz) val entry: ObjectEvent[A] = new ObjectEvent(level, v, channelName, execId, ev, clazz)
xlogger.log( xlogger.log(
ConsoleAppender.toXLevel(level), ConsoleAppender.toXLevel(level),
new ObjectMessage(entry) new ObjectMessage(entry)

View File

@ -5,7 +5,7 @@ package util
import sbt.util.Level import sbt.util.Level
import sjsonnew.JsonFormat import sjsonnew.JsonFormat
final class ObjectLogEntry[A]( final class ObjectEvent[A](
val level: Level.Value, val level: Level.Value,
val message: A, val message: A,
val channelName: Option[String], val channelName: Option[String],