How to use the daiquiri.output.TimedRotatingFile function in daiquiri

To help you get started, we’ve selected a few daiquiri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jd / daiquiri / examples / files.py View on Github external
import datetime
import logging

import daiquiri

daiquiri.setup(
    level=logging.DEBUG,
    outputs=(
        daiquiri.output.File('errors.log', level=logging.ERROR),
        daiquiri.output.TimedRotatingFile(
            'everything.log',
            level=logging.DEBUG,
            interval=datetime.timedelta(hours=1))
    )
)

logger = daiquiri.getLogger(__name__)

logger.info('only to rotating file logger')
logger.error('both log files, including errors only')
github jd / daiquiri / daiquiri / output.py View on Github external
:param suffix: The log file name suffix.
        This will be only used if no filename has been provided.
        :param program_name: Program name. Autodetected by default.
        :param interval: datetime.timedelta instance representing
        how often a new log file should be created.
        :param backup_count: the maximum number of files to rotate
        logging output between.
        """
        logpath = _get_log_file_path(filename, directory,
                                     program_name, suffix)
        handler = logging.handlers.TimedRotatingFileHandler(
            logpath,
            when='S',
            interval=self._timedelta_to_seconds(interval),
            backupCount=backup_count)
        super(TimedRotatingFile, self).__init__(handler, formatter, level)
github Mergifyio / mergify-engine / mergify_engine / utils.py View on Github external
def setup_logging():
    outputs = []

    if config.LOG_STDOUT:
        outputs.append(
            daiquiri.output.Stream(
                sys.stdout, formatter=CustomFormatter(fmt=CELERY_EXTRAS_FORMAT)
            )
        )

    if config.LOG_JSON_FILE:
        outputs.append(
            daiquiri.output.TimedRotatingFile(
                filename=config.LOG_JSON_FILE,
                level=logging.DEBUG,
                interval=datetime.timedelta(seconds=5),
                backup_count=48,
                formatter=daiquiri.formatter.JSON_FORMATTER,
            )
        )

    daiquiri.setup(
        outputs=outputs, level=(logging.DEBUG if config.DEBUG else logging.INFO),
    )
    daiquiri.set_default_log_levels(
        [
            ("celery", "INFO"),
            ("kombu", "WARN"),
            ("github.Requester", "WARN"),