def setup_logger(name=None, logfile=None, level=logging.DEBUG, formatter=None, maxBytes=<NUM_LIT:0>, backupCount=<NUM_LIT:0>, fileLoglevel=None, disableStderrLogger=False):
_logger = logging.getLogger(name or __name__)<EOL>_logger.propagate = False<EOL>_logger.setLevel(level)<EOL>stderr_stream_handler = None<EOL>for handler in list(_logger.handlers):<EOL><INDENT>if hasattr(handler, LOGZERO_INTERNAL_LOGGER_ATTR):<EOL><INDENT>if isinstance(handler, logging.FileHandler):<EOL><INDENT>_logger.removeHandler(handler)<EOL>continue<EOL><DEDENT>elif isinstance(handler, logging.StreamHandler):<EOL><INDENT>stderr_stream_handler = handler<EOL><DEDENT><DEDENT>handler.setLevel(level)<EOL>handler.setFormatter(formatter or LogFormatter())<EOL><DEDENT>if disableStderrLogger:<EOL><INDENT>if stderr_stream_handler is not None:<EOL><INDENT>_logger.removeHandler(stderr_stream_handler)<EOL><DEDENT><DEDENT>elif stderr_stream_handler is None:<EOL><INDENT>stderr_stream_handler = logging.StreamHandler()<EOL>setattr(stderr_stream_handler, LOGZERO_INTERNAL_LOGGER_ATTR, True)<EOL>stderr_stream_handler.setLevel(level)<EOL>stderr_stream_handler.setFormatter(formatter or LogFormatter())<EOL>_logger.addHandler(stderr_stream_handler)<EOL><DEDENT>if logfile:<EOL><INDENT>rotating_filehandler = RotatingFileHandler(filename=logfile, maxBytes=maxBytes, backupCount=backupCount)<EOL>setattr(rotating_filehandler, LOGZERO_INTERNAL_LOGGER_ATTR, True)<EOL>rotating_filehandler.setLevel(fileLoglevel or level)<EOL>rotating_filehandler.setFormatter(formatter or LogFormatter(color=False))<EOL>_logger.addHandler(rotating_filehandler)<EOL><DEDENT>return _logger<EOL>
Configures and returns a fully configured logger instance, no hassles.
If a logger with the specified name already exists, it returns the existing instance,
else creates a new one.

If you set the ``logfile`` parameter with a filename, the logger will save the messages to the logfile,
but does not rotate by default. If you want to enable log rotation, set both ``maxBytes`` and ``backupCount``.

Usage:

.. code-block:: python

    from logzero import setup_logger
    logger = setup_logger()
    logger.info("hello")

:arg string name: Name of the `Logger object <https://docs.python.org/2/library/logging.html#logger-objects>`_. Multiple calls to ``setup_logger()`` with the same name will always return a reference to the same Logger object. (default: ``__name__``)
:arg string logfile: If set, also write logs to the specified filename.
:arg int level: Minimum `logging-level <https://docs.python.org/2/library/logging.html#logging-levels>`_ to display (default: ``logging.DEBUG``).
:arg Formatter formatter: `Python logging Formatter object <https://docs.python.org/2/library/logging.html#formatter-objects>`_ (by default uses the internal LogFormatter).
:arg int maxBytes: Size of the logfile when rollover should occur. Defaults to 0, rollover never occurs.
:arg int backupCount: Number of backups to keep. Defaults to 0, rollover never occurs.
:arg int fileLoglevel: Minimum `logging-level <https://docs.python.org/2/library/logging.html#logging-levels>`_ for the file logger (is not set, it will use the loglevel from the ``level`` argument)
:arg bool disableStderrLogger: Should the default stderr logger be disabled. Defaults to False.
:return: A fully configured Python logging `Logger object <https://docs.python.org/2/library/logging.html#logger-objects>`_ you can use with ``.debug("msg")``, etc.