package logging_test
import (
"os"
"github.com/go-kit/log/level"
"github.com/grafana/agent/pkg/flow/logging"
)
func Example() {
sink, err := logging.WriterSink(os.Stdout, logging.SinkOptions{
Level: logging.LevelDebug,
Format: logging.FormatLogfmt,
IncludeTimestamps: false,
})
if err != nil {
panic(err)
}
controller := logging.New(sink)
component1 := logging.New(logging.LoggerSink(controller), logging.WithComponentID("outer"))
component2 := logging.New(logging.LoggerSink(component1), logging.WithComponentID("inner"))
innerController := logging.New(logging.LoggerSink(component2))
level.Info(controller).Log("msg", "hello from the controller!")
level.Info(component1).Log("msg", "hello from the outer component!")
level.Info(component2).Log("msg", "hello from the inner component!")
level.Info(innerController).Log("msg", "hello from the inner controller!")
}