cloudquery / plugin-sdk

CloudQuery Go SDK for source and destination plugins
Mozilla Public License 2.0
22 stars 24 forks source link

When redirecting the plugin output to a file, colors are added to the output #102

Closed erezrokah closed 2 years ago

erezrokah commented 2 years ago

Describe the bug

Not sure if this belongs here or in https://github.com/cloudquery/cloudquery.

When doing go run main.go serve > output.txt in a plugin's repo (after cloning it), the file will contain the following:

11:40AM INF fetch start table=azure_datalake_analytics_accounts
11:40AM INF fetch start table=azure_frontdoor_doors
11:40AM INF fetch start table=azure_datalake_store_accounts
11:40AM INF fetch start table=azure_compute_virtual_machines
11:40AM INF fetch start table=azure_eventhub_namespaces
11:40AM INF fetch start table=azure_cdn_profiles
11:40AM INF fetch start table=azure_iothub_devices
11:40AM INF fetch start table=azure_container_registries
11:40AM INF fetch start table=azure_container_managed_clusters
11:40AM INF fetch start table=azure_compute_disks
11:40AM INF fetch start table=azure_keyvault_managed_hsms
11:40AM INF fetch start table=azure_compute_virtual_machine_scale_sets
11:40AM INF fetch start table=azure_authorization_role_assignments
11:40AM INF fetch start table=azure_keyvault_vaults
11:40AM INF fetch start table=azure_batch_accounts
11:40AM INF fetch start table=azure_authorization_role_definitions
11:40AM INF fetch start table=azure_logic_workflows
11:40AM INF fetch start table=azure_mariadb_servers
11:40AM INF fetch start table=azure_cosmosdb_accounts

This makes it harder to debug plugins

Expected Behavior

The output file should not have special characters

Steps to Reproduce

  1. git@github.com:cloudquery/cloudquery.git
  2. cd plugins/source/gcp
  3. go run main.go serve > output.txt

Examine content of output.txt

Possible Solution

Support NO_COLOR=true env variable and/or automatically set it when piping output to a file

Provider and CloudQuery version

v2

Additional Context

No response

yevgenypats commented 2 years ago

maybe we should disable colors in the plugins at all but otherwise I would add --color and set no color as default. As a work around you can use --log-format=json this will be with no colors

erezrokah commented 2 years ago

Closing this as wontfix for now