#Get logs from running command before its completion

1 messages · Page 1 of 1 (latest)

silk walrus
#

I can only get the logs from a running command when using the logOuput ConnectOption. Is there a way to use the .stdout() function on the container object to get the output?
When using the stdout function I only get the output once the command has finished its execution. When I use the logOutput Writeable I get all the logs, indistinguishable from each other.
Does somebody know a way to get "live" logs from a certain container?

There is a similar post here, but I don't think it is the same: https://discordapp.com/channels/707636530424053791/1153523694958809098

Code example:

await connect(
  async (client) => {
    // [...]

    const builder = client
      .container()
      .from('node:18-alpine')
      .withExec(['apk', 'add', '--no-cache', 'git'])
      .withWorkdir('/app')
      .withDirectory('/app', deps.directory(workDir))
      .withExec(packageManager.build);
    logsOutput?.write(await builder.stdout()); // Only gets the output after execution.
    logsOutput?.end();

    // [...]
  },
  { LogOutput: logsOutput }, // Outputs "too much" information, I only need the "live feed" from the command of the builder container.
);
elder fern
#

Hi there it's not possible currently via the stdout interface. Could you open an issue for it ? 🙏

silk walrus
#

Hey @elder fern. Thank you for your quick answer. Is there a reliable way to filter the output from logOutput?

elder fern
#

@silk walrus we generally use Dagger Cloud for this ourselves since it provides depper insights about what's happening with the pipeline

#

Unfortunately there's no programatic way to filter that output today since it's something internally handled by the engine and we haven't had the need so far to provide a more structured log output

#

we are sending the engine telemetry in a structured way to Dagger Cloud so we can have real time logs and insights there but we don't expose that to the user since it's a custom protocol that is not user friendly

silk walrus
#

Thank you @elder fern . I went through the source code for a bit but could only find the part where the process stderr gets passed to the Writable.

#

Can we create a local endpoint that emulates the dagger cloud endpoint to get the telemetry? Is there any documentation on this?

elder fern
elder fern
#

keep in mind that the flag is experimental and it's not guaranteed that this will be supported in the future

silk walrus
elder fern
silk walrus
#

Thank you so much @elder fern. The "custom dagger cloud" approach has worked and i am receiving realtime logs along with even more detailed information.

tame basalt