Skip to content

Commit

Permalink
Update fansi to 0.3.1 (ScalablyTyped#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
scala-steward authored May 23, 2022
1 parent 9d7fd68 commit 181ade5
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ object Main {
val massaged = kvs.flatMap {
case (header, value) => Seq[Str](Key(header.padTo(headerLength, ' ')), value, "\n")
}
Str.join(massaged: _*)
Str.join(massaged)
}

def main(args: Array[String]): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object Interface {
println("\u001b[H")

def row[N: Numeric](title: String, num: N) =
println(fansi.Str.join(title, ": ", fansi.Bold.On(num.toString)).render)
println(fansi.Str.join(List(title, ": ", fansi.Bold.On(num.toString))).render)

row("Successes", numSucceded)
row("Failed", numFailed)
Expand Down
15 changes: 8 additions & 7 deletions logging/src/main/scala/com/olvind/logging/Formatter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ object Formatter {
@inline def apply[T: Formatter](t: T): Str = implicitly[Formatter[T]].apply(t)

implicit def Tuple2Formatter[T1: Formatter, T2: Formatter]: Formatter[(T1, T2)] = {
case (t1, t2) => Str.join(Formatter(t1), ", ", Formatter(t2))
case (t1, t2) => Str.join(List(Formatter(t1), ", ", Formatter(t2)))
}

implicit def Tuple3Formatter[T1: Formatter, T2: Formatter, T3: Formatter]: Formatter[(T1, T2, T3)] = {
case (t1, t2, t3) => Str.join(Formatter(t1), ", ", Formatter(t2), ", ", Formatter(t3))
case (t1, t2, t3) => Str.join(List(Formatter(t1), ", ", Formatter(t2), ", ", Formatter(t3)))
}

implicit def Tuple4Formatter[T1: Formatter, T2: Formatter, T3: Formatter, T4: Formatter]
: Formatter[(T1, T2, T3, T4)] = {
case (t1, t2, t3, t4) => Str.join(Formatter(t1), ", ", Formatter(t2), ", ", Formatter(t3), ", ", Formatter(t4))
case (t1, t2, t3, t4) =>
Str.join(List(Formatter(t1), ", ", Formatter(t2), ", ", Formatter(t3), ", ", Formatter(t4)))
}

implicit def EitherFormatter[L: Formatter, R: Formatter]: Formatter[Either[L, R]] =
Expand All @@ -43,7 +44,7 @@ object Formatter {
}

arr(idx - 1) = "]"
Str.join(arr: _*)
Str.join(arr)
}

implicit def ArrayFormatter[T: Formatter]: Formatter[Array[T]] =
Expand All @@ -61,7 +62,7 @@ object Formatter {
}

arr(idx - 1) = "]"
Str.join(arr: _*)
Str.join(arr)
}

implicit def MapFormatter[K: Formatter, V: Formatter]: Formatter[Map[K, V]] =
Expand All @@ -82,7 +83,7 @@ object Formatter {
}

arr(idx - 1) = "]"
Str.join(arr: _*)
Str.join(arr)
}

implicit val StrFormatter: Formatter[Str] = x => x
Expand All @@ -94,7 +95,7 @@ object Formatter {
implicit val URIFormatter: Formatter[URI] = _.toString

implicit def ThrowableFormatter[Th <: Throwable]: Formatter[Th] = {
case th: Throwable if th.getMessage != null => Str.join(th.getClass.getName, ": ", th.getMessage)
case th: Throwable if th.getMessage != null => Str.join(List(th.getClass.getName, ": ", th.getMessage))
case th: Throwable => th.getClass.getName
}
}
36 changes: 19 additions & 17 deletions logging/src/main/scala/com/olvind/logging/Pattern.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,25 @@ object Pattern {
val source = if (t.source.startsWith("\"") || t.source.startsWith("s\"")) "" else t.source

Str.join(
Color(prefixFor(m.logLevel)),
" ",
Subtle(m.instant.toString),
" ",
Subtle(Formatter(new File(m.file.value))),
":",
Subtle(Formatter(m.line.value)),
" ",
Color(source),
" ",
Color(Formatter(t.value)),
" ",
Subtle(Formatter(ctx)),
throwable match {
case None => ""
case Some(th) => Subtle(formatThrowable(th))
},
List(
Color(prefixFor(m.logLevel)),
" ",
Subtle(m.instant.toString),
" ",
Subtle(Formatter(new File(m.file.value))),
":",
Subtle(Formatter(m.line.value)),
" ",
Color(source),
" ",
Color(Formatter(t.value)),
" ",
Subtle(Formatter(ctx)),
throwable match {
case None => ""
case Some(th) => Subtle(formatThrowable(th))
},
),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion project/Deps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Deps {
val osLib = "com.lihaoyi" %% "os-lib" % "0.7.7"
val sourcecode = "com.lihaoyi" %% "sourcecode" % "0.2.8"
val scalatest = "org.scalatest" %% "scalatest" % "3.2.9"
val fansi = "com.lihaoyi" %% "fansi" % "0.2.14"
val fansi = "com.lihaoyi" %% "fansi" % "0.3.1"
val bloop = "ch.epfl.scala" %% "bloop-frontend" % "1.4.11"
val scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.3.0"
val scopt = "com.github.scopt" %% "scopt" % "4.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@ object WrapSbtLogger {
val source = if (t.source.startsWith("\"") || t.source.startsWith("s\"")) "" else t.source

Str.join(
subtle(Str.join(Formatter(new sbt.File(m.file.value)), ":", Formatter(m.line.value))),
" ",
subtle(source),
" ",
color(Formatter(t.value)),
" ",
subtle(Formatter(ctx.updated("ms", Formatter(java.time.Duration.between(started, m.instant).toMillis)))),
throwable match {
case None => ""
case Some(th) => subtle(Pattern.formatThrowable(th))
},
List(
subtle(Str.join(List(Formatter(new sbt.File(m.file.value)), ":", Formatter(m.line.value)))),
" ",
subtle(source),
" ",
color(Formatter(t.value)),
" ",
subtle(Formatter(ctx.updated("ms", Formatter(java.time.Duration.between(started, m.instant).toMillis)))),
throwable match {
case None => ""
case Some(th) => subtle(Pattern.formatThrowable(th))
},
),
)
}
}
Expand Down

0 comments on commit 181ade5

Please sign in to comment.