Skip to content
This repository was archived by the owner on Apr 11, 2022. It is now read-only.
This repository was archived by the owner on Apr 11, 2022. It is now read-only.

Stream Stdout/Stderr instead of buffering #26

@muuki88

Description

@muuki88

Currently all logging is buffered inside a ByteString builder,
which let's long running tasks appear unresponsive (e.g. rjs
optimize).

I tried to get my head around the Engine class and implementing a simple
logging trait where other logging implementations, such as sbt.streams,
can easily be wrapped.

However I failed handling the ByteStrings and the context.become calls.
My Logger trait looks essentially like this

trait Logger {
    // var in trait?
    var outputBuilder = ByteString.newBuilder

    def info(msg: => String): Unit

    def infoRaw(bytes: => ByteString): Unit = {
      outputBuilder ++= bytes
      outputBuilder = outputBuilder.result.utf8String match {
        case content if !content.contains("\n") => outputBuilder ++= bytes
        case content =>
          val rest = content.split("\n") match {
            case Array(out, rest) => info(out); rest
          }
          ByteString.newBuilder ++= ByteString(rest, "UTF-8")
      }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions