(self)
return self._logger
Logger that logs to both console and a log file.

        If Alfred's debugger is open, log level will be ``DEBUG``,
        else it will be ``INFO``.

        Use :meth:`open_log` to open the log file in Console.

        :returns: an initialised :class:`~logging.Logger`
Logger that logs to both console and a log file.
Logger that logs to both console and a log file .
def logger(self):
        """Logger that logs to both console and a log file.

        If Alfred's debugger is open, log level will be ``DEBUG``,
        else it will be ``INFO``.

        Use :meth:`open_log` to open the log file in Console.

        :returns: an initialised :class:`~logging.Logger`

        """
        if self._logger:
            return self._logger

        # Initialise new logger and optionally handlers
        logger = logging.getLogger('')

        # Only add one set of handlers
        # Exclude from coverage, as pytest will have configured the
        # root logger already
        if not len(logger.handlers):  # pragma: no cover

            fmt = logging.Formatter(
                '%(asctime)s %(filename)s:%(lineno)s'
                ' %(levelname)-8s %(message)s',
                datefmt='%H:%M:%S')

            logfile = logging.handlers.RotatingFileHandler(
                self.logfile,
                maxBytes=1024 * 1024,
                backupCount=1)
            logfile.setFormatter(fmt)
            logger.addHandler(logfile)

            console = logging.StreamHandler()
            console.setFormatter(fmt)
            logger.addHandler(console)

        if self.debugging:
            logger.setLevel(logging.DEBUG)
        else:
            logger.setLevel(logging.INFO)

        self._logger = logger

        return self._logger
def logger ( self ) : if self . _logger : return self . _logger # Initialise new logger and optionally handlers logger = logging . getLogger ( '' ) # Only add one set of handlers # Exclude from coverage, as pytest will have configured the # root logger already if not len ( logger . handlers ) : # pragma: no cover fmt = logging . Formatter ( '%(asctime)s %(filename)s:%(lineno)s' ' %(levelname)-8s %(message)s' , datefmt = '%H:%M:%S' ) logfile = logging . handlers . RotatingFileHandler ( self . logfile , maxBytes = 1024 * 1024 , backupCount = 1 ) logfile . setFormatter ( fmt ) logger . addHandler ( logfile ) console = logging . StreamHandler ( ) console . setFormatter ( fmt ) logger . addHandler ( console ) if self . debugging : logger . setLevel ( logging . DEBUG ) else : logger . setLevel ( logging . INFO ) self . _logger = logger return self . _logger