2023-01-11 21:34:27 +00:00
|
|
|
package cluster
|
2022-06-24 15:26:17 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/testcontainers/testcontainers-go"
|
|
|
|
)
|
|
|
|
|
2022-11-01 19:03:23 +00:00
|
|
|
type LogConsumer struct {
|
2022-06-24 15:26:17 +00:00
|
|
|
Prefix string
|
|
|
|
}
|
|
|
|
|
2022-11-01 19:03:23 +00:00
|
|
|
var _ testcontainers.LogConsumer = (*LogConsumer)(nil)
|
2022-06-24 15:26:17 +00:00
|
|
|
|
2022-11-01 19:03:23 +00:00
|
|
|
func (c *LogConsumer) Accept(log testcontainers.Log) {
|
2022-06-24 15:26:17 +00:00
|
|
|
switch log.LogType {
|
|
|
|
case "STDOUT":
|
|
|
|
fmt.Fprint(os.Stdout, c.Prefix+" ~~ "+string(log.Content))
|
|
|
|
case "STDERR":
|
|
|
|
fmt.Fprint(os.Stderr, c.Prefix+" ~~ "+string(log.Content))
|
|
|
|
}
|
|
|
|
}
|