<commit_before>package empire

import (
	"encoding/json"
	"io"

	"github.com/docker/docker/pkg/jsonmessage"
	"github.com/remind101/kinesumer"
)

func (e *Empire) StreamLogs(a *App, w io.Writer) error {
	k, err := kinesumer.NewDefault(a.ID)
	if err != nil {
		return err
	}

	_, err = k.Begin()
	if err != nil {
		return err
	}
	defer k.End()

	for {
		rec := <-k.Records()
		msg := jsonmessage.JSONMessage{Status: string(rec.Data())}
		if err := json.NewEncoder(w).Encode(&msg); err != nil {
			return err
		}
	}
}
<commit_msg>Stream raw text instead of JSON.<commit_after>package empire

import (
	"io"

	"github.com/remind101/kinesumer"
)

func (e *Empire) StreamLogs(a *App, w io.Writer) error {
	k, err := kinesumer.NewDefault(a.ID)
	if err != nil {
		return err
	}

	_, err = k.Begin()
	if err != nil {
		return err
	}
	defer k.End()

	for {
		rec := <-k.Records()
		msg := append(rec.Data(), '\n')
		w.Write(msg)
	}
}

{'fraction_non_alphanumeric': 0.170995670995671, 'fraction_numerical': 0.006493506493506494, 'mean_word_length': 3.223744292237443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4237239', 'n_tokens_mistral': 403, 'n_tokens_neox': 375, 'n_words': 87}