How to use the daiquiri.output.File 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 / pifpaf / pifpaf / __main__.py View on Github external
def main(ctx, verbose=False, debug=False, log_file=None,
         env_prefix=None, global_urls_variable=None):
    formatter = daiquiri.formatter.ColorFormatter(
        fmt="%(color)s%(levelname)s "
        "[%(name)s] %(message)s%(color_stop)s")

    outputs = [
        daiquiri.output.Stream(sys.stderr, formatter=formatter)
    ]

    if log_file:
        outputs.append(daiquiri.output.File(log_file,
                                            formatter=formatter))

    ctx.obj = {
        "debug": debug,
    }
    if env_prefix is not None:
        ctx.obj['env_prefix'] = env_prefix
    if global_urls_variable is not None:
        ctx.obj['global_urls_variable'] = global_urls_variable

    if debug:
        level = logging.DEBUG
    elif verbose:
        level = logging.INFO
    else:
        level = logging.WARNING
github alin23 / spfy / spfy / log.py View on Github external
def get_logger(level=logging.INFO):
    logdir = pathlib.Path.home().joinpath('.logs')
    if not logdir.exists():
        logdir.mkdir(parents=True)

    daiquiri.setup(outputs=(
        daiquiri.output.STDERR,
        daiquiri.output.File(directory=logdir)
    ), level=level)

    logger = daiquiri.getLogger()

    if os.getenv('FIRE_DEBUG'):
        logger.setLevel(logging.DEBUG)

    return logger
github gnocchixyz / gnocchi / gnocchi / service.py View on Github external
group=None if group == "DEFAULT" else group)

    conf.register_cli_opts(opts._cli_options)

    workers = utils.get_default_workers()
    conf.set_default("workers", workers, group="metricd")
    conf.set_default("parallel_operations", workers)

    conf(args, project='gnocchi', validate_default_values=True,
         default_config_files=default_config_files,
         version=gnocchi.__version__)

    utils.parallel_map.MAX_WORKERS = conf.parallel_operations

    if not log_to_std and (conf.log_dir or conf.log_file):
        outputs = [daiquiri.output.File(filename=conf.log_file,
                                        directory=conf.log_dir)]
    else:
        outputs = [daiquiri.output.STDERR]

    if conf.use_syslog:
        outputs.append(
            daiquiri.output.Syslog(facility=conf.syslog_log_facility))

    if conf.use_journal:
        outputs.append(daiquiri.output.Journal())

    daiquiri.setup(outputs=outputs)
    if logging_level is None:
        if conf.debug:
            logging_level = logging.DEBUG
        elif conf.verbose:
github jd / daiquiri / examples / output.py View on Github external
import logging
import sys

import daiquiri

# Log both to stdout and as JSON in a file called /dev/null. (Requires
# `python-json-logger`)
daiquiri.setup(level=logging.INFO, outputs=(
    daiquiri.output.Stream(sys.stdout),
    daiquiri.output.File("/dev/null",
                         formatter=daiquiri.formatter.JSON_FORMATTER),
    ))

logger = daiquiri.getLogger(__name__, subsystem="example")
logger.info("It works and log to stdout and /dev/null with JSON")
github CermakM / jupyter-require / jupyter_require / __init__.py View on Github external
from .notebook import load_js
from .notebook import load_css

from .core import communicate

from .core import execute_with_requirements
from .core import execute
from .core import safe_execute
from .core import require

from IPython import get_ipython

daiquiri.setup(
    level=logging.DEBUG,
    outputs=[
        daiquiri.output.File(
            level=logging.DEBUG,
            filename='.log',
            formatter=daiquiri.formatter.ColorFormatter(
                fmt="%(asctime)s [%(process)d] %(color)s%(levelname)-8.8s %(name)s:"
                    "%(lineno)d: [JupyterRequire] %(message)s%(color_stop)s"
            )),
        daiquiri.output.Stream(
            level=logging.WARN,
            formatter=daiquiri.formatter.ColorFormatter(
                fmt="%(asctime)s [%(process)d] %(color)s%(levelname)-8.8s %(name)s:"
                    "%(lineno)d: [JupyterRequire] %(message)s%(color_stop)s"
            )
        ),
    ],
)
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')