#Live logs

1 messages ยท Page 1 of 1 (latest)

tribal coral
#

There's ways to do it yes. First, if you're not using a module, dagger run will give you a nice TUI with live progress. You basically prefix your usual command with dagger run ....

left jungle
#

I'm using the go SDK and embedding in another program. So TUI logs wont work for me. Currently it just hangs for a while and then dumps the logs

#

So im trying to see if there are any hooks i can use to access the live logs directly

compact ridge
#

@left jungle there's no native way of doing this. Here's something relatively safe you can do.

func main() {
    ctx := context.Background()
    c, _ := dagger.Connect(ctx, dagger.WithLogOutput(os.Stdout))
    c.Container().From("alpine").WithExec([]string{"sh", "-c", "while true; do echo hello | sed 's/^/[SOME_PREFIX] /'; sleep 1; done"}).Stdout(ctx)

}
#

^ os.Stdout can be whatever Writer you need and then you can filter the logs you need by looking for SOME_PREFIX

proud sage
#

are dagger modules and sdk supported with dagger run? because I thought run doesn't support modules as it's not sdk integrated

compact ridge
tribal coral
compact ridge
#

and then pipe to whatever he needs

tribal coral
#

But there's something else. The progress you see in dagger run is based on OpenTelemetry. So your app could have its own Otel exporter, even spitting to the screen if you want. It would integrate with Dagger's telemetry out of the box.

#

The WithLogOutput is a bit more lower level but ok if it works for you.

compact ridge
tribal coral
#

Yes but I also think it looks more complex than it is.

left jungle
#

The otel option sounds interesting, any examples that you can point me to?

compact ridge
#

cc @unkempt heart

#

lol, this was alread your thread Seth ๐Ÿ˜„

#

lets come up with an example on how to get the log from the collector ๐Ÿ™