Altinity / clickhouse-backup

Tool for easy backup and restore for ClickHouse® using object storage for backup files.
https://altinity.com
Other
1.29k stars 227 forks source link

Logs of CLI commands should go to stderr? #969

Closed lainiwa closed 3 months ago

lainiwa commented 4 months ago

Currently clickhouse-backup logs everything to stdout. This makes it harder to script.

An example:

# Otherwise `clickhouse-backup list` will contaminate stdout
export LOG_LEVEL=error

# ...
# Override S3_PATH: we cannot do that in a http request
LATEST_BACKUP_SHARD_5=$(S3_PATH=clickhouse/shard-5 clickhouse-backup list remote latest)

This works, but it will swallow all the non-error info, that might be valuable otherwise.

Slach commented 4 months ago

currently not, could you help us with race conditions when switching to zerolog https://github.com/Altinity/clickhouse-backup/pull/670, this log library can write different log level to different steams

lainiwa commented 3 months ago

Unfortunately I don't think I could help as my golang experience is none.

Anyways, maybe #670 is only tangentially related to this issue: writing different log levels to different streams might be useful for daemon-like services, like clickhouse-backup server or clickhouse-backup watch, but I think CLI utils should redirect strictly all logs to stderr, as opposed to the actual return value.

Slach commented 3 months ago

ok. let's change current behavior