blob: d6c5f050db124d5d223688cd65f6f4061adc53be [file] [log] [blame]
Lorenz Brun52f7f292020-06-24 16:42:02 +02001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package main
18
19import (
Serge Bazanski686444e2020-12-21 14:21:14 +010020 "fmt"
21 "io"
Lorenz Brun52f7f292020-06-24 16:42:02 +020022 "log"
23 "os"
Lorenz Brun52f7f292020-06-24 16:42:02 +020024
Serge Bazanski31370b02021-01-07 16:31:14 +010025 "source.monogon.dev/metropolis/pkg/logbuffer"
Lorenz Brun52f7f292020-06-24 16:42:02 +020026)
27
Serge Bazanski686444e2020-12-21 14:21:14 +010028// prefixedStdout is a os.Stdout proxy that prefixes every line with a constant
29// prefix. This is used to show logs from two Metropolis nodes without getting
30// them confused.
31// TODO(q3k): move to logging API instead of relying on qemu stdout, and remove
32// this function.
33func prefixedStdout(prefix string) io.ReadWriter {
34 lb := logbuffer.NewLineBuffer(2048, func(l *logbuffer.Line) {
35 fmt.Fprintf(os.Stdout, "%s%s\n", prefix, l.Data)
36 })
37 // Make a ReaderWriter from LineBuffer (a Reader), by combining into an
38 // anonymous struct with a io.MultiReader() (which will always return EOF
39 // on every Read if given no underlying readers).
40 return struct {
41 io.Reader
42 io.Writer
43 }{
44 Reader: io.MultiReader(),
45 Writer: lb,
46 }
47}
48
Lorenz Brun52f7f292020-06-24 16:42:02 +020049func main() {
Serge Bazanski0ed2f962021-03-15 16:39:30 +010050 log.Fatal("unimplemented")
Lorenz Brun52f7f292020-06-24 16:42:02 +020051}