Skip to content

Commit

Permalink
?
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Jun 3, 2024
1 parent 482a1aa commit 8f9894c
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ private object VariableInspectorApiImpl {
)
.map(_.render)
.mkString
.replaceAll(java.util.regex.Pattern.quote("(") + "\n\\s+", "(")
.replaceAll("\n\\s+", " ")
.replaceAll("\n", " ")
.replaceAll(java.util.regex.Pattern.quote("(") + "\r?\n\\s+", "(")
.replaceAll("\r?\n\\s+", " ")
.replaceAll("\r?\n", " ")
},
varType = tprint.render(TPrintColors.BlackWhite).render,
isMatrix = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ object ScalaKernel extends CaseApp[Options] {
case (trigger, auto) =>
Seq("Auto dependency:", s" Trigger: $trigger") ++ auto.map(dep => s" Adds: $dep")
}
.mkString("\n")
.mkString(System.lineSeparator())
)

val interpreterEc = singleThreadedExecutionContext("scala-interpreter")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,21 @@ final class ZeromqSocketImpl(

ensureOpened()

log.debug(
"Sending:\n" +
log.debug {
val nl = System.lineSeparator()
"Sending:" + nl +
" header: " +
Try(new String(message.header, "UTF-8"))
.toOption
.getOrElse(message.header.toString) +
"\n" +
nl +
" content: " +
Try(new String(message.content, "UTF-8"))
.toOption
.getOrElse(message.content.toString) +
"\n" +
nl +
" idents: " + identsAsStrings(message.idents)
)
}

for (c <- message.idents)
channel.send(c.toArray, ZMQ.SNDMORE)
Expand Down Expand Up @@ -196,17 +197,18 @@ final class ZeromqSocketImpl(

if (expectedSignature == signature || !enableMac) {
log.debug {
val nl = System.lineSeparator()
val headerStr = Try(new String(message.header, UTF_8))
.getOrElse(message.header.toString)
s"Received on $uri:\n" +
s"Received on $uri:" + nl +
" header: " +
headerStr +
"\n" +
nl +
" content: " +
Try(new String(message.content, "UTF-8"))
.toOption
.getOrElse(message.content.toString) +
"\n" +
nl +
" idents: " + identsAsStrings(message.idents)
}
Some(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object InputManager {

res match {
case Success(value) =>
val b0 = ByteBuffer.wrap((value + "\n").getBytes(UTF_8)).asReadOnlyBuffer()
val b0 = ByteBuffer.wrap((value + System.lineSeparator()).getBytes(UTF_8)).asReadOnlyBuffer()
bufferOpt = Some(b0)
case Failure(_: NoMoreInputException) =>
done = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final case class MessageHandler(
): Option[Stream[IO, (Channel, RawMessage)]] =
handle(channel, message).map {
case Left(e) =>
log.error(s"Ignoring error decoding message\n$message", e)
log.error(s"Ignoring error decoding message${System.lineSeparator()}$message", e)
Stream.empty
case Right(s) => s
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ final case class Kernel(

immediateHandlers.handleOrLogError(channel, rawMessage, log) match {
case None =>
log.warn(s"Ignoring unhandled message on $channel:\n$rawMessage")
log.warn(s"Ignoring unhandled message on $channel:${System.lineSeparator()}$rawMessage")
IO.unit

case Some(output) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import java.lang.management.ManagementFactory

import almond.logger.Level

import scala.annotation.tailrec

final class PrintStreamLogger(
val level: Level,
out: PrintStream,
Expand All @@ -33,21 +31,8 @@ final class PrintStreamLogger(
b += ' '
b ++= message

@tailrec
def addException(ex: Throwable): Unit =
if (ex != null) {
b += '\n' // FIXME Not portable
b ++= ex.toString
for (elem <- ex.getStackTrace) {
b ++= "\n " // FIXME Not portable
b ++= elem.toString
}
addException(ex.getCause)
}

addException(exception)

out.println(b.result())
exception.printStackTrace(out)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final case class ClientStreams(
case Right((`channel`, m)) =>
m.decodeAs[T] match {
case Left(err) =>
throw new Exception(s"Error decoding message: $err\n$m")
throw new Exception(s"Error decoding message: $err${System.lineSeparator()}$m")
case Right(m0) =>
m0
}
Expand All @@ -58,7 +58,7 @@ final case class ClientStreams(
case Left((`channel`, m)) if m.header.msg_type == msgType.messageType =>
m.decodeAs[T] match {
case Left(err) =>
throw new Exception(s"Error decoding message: $err\n$m")
throw new Exception(s"Error decoding message: $err${System.lineSeparator()}$m")
case Right(m0) =>
m0
}
Expand Down

0 comments on commit 8f9894c

Please sign in to comment.