cloudflare / workers-sdk

โ›…๏ธ Home to Wrangler, the CLI for Cloudflare Workersยฎ
https://developers.cloudflare.com/workers/
Apache License 2.0
2.58k stars 665 forks source link

๐Ÿš€ Feature Request: quiet mode for wrangler #2415

Closed MinmoTech closed 1 year ago

MinmoTech commented 1 year ago

Describe the solution

I accidentally reported this on the original wrangler repo first: https://github.com/cloudflare/wrangler2/issues/2615

A kind of warning/link to the wrangler2 repo might be nice there :)

My actual issue:

I want to use r2 and d1 in scripts with wrangler. Wrangler already has a nice json output (when redirecting stdout), but it also prints spammy lines before that output:


๐ŸŒ€ Mapping SQL input into an array of statements
๐ŸŒ€ Parsing 1 statements
๐Ÿšฃ Executed 1 command in 32.160559952259064ms
[
  {
    "results": [
      {
        "test1": "test",
        "test2": "test",
        "test3": 0,
        "test4": "test"
      }
    ],
    "success": true,
    "meta": {
      "duration": 32.160559952259064,
      "last_row_id": null,
      "changes": null,
      "served_by": "primary-fc09486d-3681-4906-a109-0b5e3d7737ab.db3",
      "internal_stats": null
    }
  }
]

The command I ran was NO_D1_WARNING=true wrangler d1 execute test_db --command='SELECT * FROM test_table

I would like a quiet mode for wrangler that suppresses the lines before the json output.

Describe the alternatives

Are there any alternatives to solving this problem? If so, what was your experience with them?

Those first few lines could be printed to stderr instead of to stdout.

rozenmd commented 1 year ago

Fair ask - we do have WRANGLER_LOG as detailed in https://developers.cloudflare.com/workers/wrangler/system-environment-variables/ but I don't know if it'll handle this case, i'll add it to our backlog

MinmoTech commented 1 year ago

I have now tested WRANGLER_LOG, with level log it still includes the messages with emoji when piping, on info and lower it does not output anything when piping.

On level info when not piping it correctly outputs just the table.

So if the piping behavior would be fixed this would be a solution :+1:

Thanks already!

lovette commented 2 months ago

In my search for a --quiet CLI option for deploy, I stumbled across WRANGLER_LOG, which is helpful... but any chance there's a way to silence the ๐ŸŒŽ Uploading... (#/#) message? It's output even for none and error which seems odd.