Instead of using custom keys in context.Context, use the logr methods for context access. This ensures that this logging adapter is compatible with others that use logr for contextual logging.
In the server command, look for a logr.Logger in the command context, and don't replace it if one is supplied by the caller. Since it's done in the PersistentPreRun, the caller can add their own logger to the returned cobra.Command before it gets invoked.
Instead of using custom keys in
context.Context
, use the logr methods for context access. This ensures that this logging adapter is compatible with others that use logr for contextual logging.In the server command, look for a
logr.Logger
in the command context, and don't replace it if one is supplied by the caller. Since it's done in thePersistentPreRun
, the caller can add their own logger to the returnedcobra.Command
before it gets invoked.