wobcom/rcli

Don't log verbose by default

Opened this issue · 1 comments

Current behavior:
rcli always logs to stdout. This makes parsing the structured output a pain.

rcli exec -o json device.example.com "show interface" | jq .
parse error: Invalid numeric literal at line 1, column 15

Expected behavior:

Option 1:

  • Don't log info/verbose by default
  • When -v or --verbose is set, log to stderr
  • always log errors to stderr

This is equivalent to the behavior of curl.

Option 2:

  • Only log to stdout when no pipe is attached to stdout
    • can be checked using os.ModeCharDevice
  • errors log to stderr

I prefer Option 1.

Nevermind, apparently there was an old version of the flake pinned in our repo. The current main logs to stderr.
This reduces the scope of the issue to:

  • Only log anything else then error when -v/--version is set.