UpstreetAI / monorepo

Build and deploy AI Agents, fast.
https://upstreet.ai
3 stars 1 forks source link

[SDK] Better error logging, logdump #434

Open SaadBazaz opened 2 weeks ago

SaadBazaz commented 2 weeks ago

Commands like usdk create can crash at any point. Currently, it's hard for developers to share logs as they have to copy-paste their entire chat.

Having a log file with "redacted" tokens might make it easiers for devs to share errors. Also, the content of the logfile can be directly uploaded to Telemetry like Sentry for error capture.

Possible approach

We can try-catch the CLI and then dump the stack trace + questionsSoFar into a .log file, stored in either the same folder as a file called .usdk-crash.dump maybe. Or, could be a JSON file. Really depends on international standards. See how npm manages it here (this should be a very helpful example, maybe we can just piggyback off of npm's or node's existing crash mechanisms).

I want more thoughts on this.

SaadBazaz commented 2 weeks ago

Can this be done here? https://github.com/UpstreetAI/monorepo/blob/2fcdfa1d2a847d32c36c5ce700f8feb906eff43c/packages/usdk/cli.js#L2039

Pseudocode:

  try {
    await program.parseAsync();
  }
  catch(error) {
    // 1. log error in console
    console.error(error)

    // 2. show stack trace

    // 3. Write a log to file

    // 4. Display error, and path to log file
    console.info("USDK crashed. The error log is in ", pathToErrorFile)
  }
AbdurrehmanSubhani commented 2 weeks ago

Yes definitely a good addition, would help bridge crash/error context gap between devs and users

avaer commented 1 week ago

Logs are already being written via winston.

Although it is not currently done, we could print the log location on a crash.

AbdurrehmanSubhani commented 1 week ago

Added a PR for better more reliable log dump to file and display log file path on crash: https://github.com/UpstreetAI/monorepo/pull/506