Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Allow logging to stdout instead of stderr #433

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rsnk96
Copy link

@rsnk96 rsnk96 commented Dec 29, 2021

Allows users to define logging to stdout instead of stderr

  • All instances of disableStdErr are removed. Instead, the below two parameters are added where relevant in the code:
    • log_stream: Used when setting up loggers
    • disable_stream_loggers: Used when cleaning up logging handlers
  • A user can disable stdout+stderr logging altogether by passing log_stream=None

How the code was verified:

# Default behaviour: Use stderr
>>> import logzero
>>> logzero.logger.handlers

[<StreamHandler <stderr> (DEBUG)>]
# Sample usage of stdout
>>> import logzero
>>> custom_logger_1 = logzero.setup_logger(log_stream='stdout')
>>> custom_logger_1.handlers

[<StreamHandler <stdout> (DEBUG)>]
# Sample usage of neither stdout nor stderr
>>> import logzero
>>> custom_logger_2 = logzero.setup_logger(log_stream=None)
>>> custom_logger_2.handlers

[]
# What happens when invalid stream type is passed
>>> import logzero
>>> custom_logger_3 = logzero.setup_logger(log_stream='streamy_stream')

Log stream must be one of `'stderr'`, `'stdout'` or `None`. Using `'stderr'`

Mentioned at #340 too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant