How to use the daiquiri.formatter.ColorExtrasFormatter 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 AlexsLemonade / refinebio / common / data_refinery_common / logging.py View on Github external
# This is the local handler
    handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(daiquiri.formatter.ColorExtrasFormatter(fmt=FORMAT_STRING, keywords=[]))
    logger.logger.addHandler(handler)

    # This is the Sentry handler
    if "data_refinery_api" in name:
        raven_dsn = get_env_variable_gracefully("RAVEN_DSN_API", False)
    else:
        raven_dsn = get_env_variable_gracefully("RAVEN_DSN", False)
    if raven_dsn:
        from raven.contrib.django.handlers import SentryHandler

        handler = SentryHandler()
        handler.setFormatter(
            daiquiri.formatter.ColorExtrasFormatter(fmt=FORMAT_STRING, keywords=[])
        )
        handler.setLevel(logging.WARNING)
        logger.logger.addHandler(handler)

    return logger
github Mergifyio / mergify-engine / mergify_engine / utils.py View on Github external
def utcnow():
    return datetime.datetime.now(tz=datetime.timezone.utc)


def unicode_truncate(s, length, encoding="utf-8"):
    """Truncate a string to length in bytes.

    :param s: The string to truncate.
    :param length: The length in number of bytes — not characters."""
    return s.encode(encoding)[:length].decode(encoding, errors="ignore")


class CustomFormatter(
    daiquiri.formatter.ColorExtrasFormatter, celery.app.log.TaskFormatter
):
    pass


CELERY_EXTRAS_FORMAT = (
    "%(asctime)s [%(process)d] %(color)s%(levelname)-8.8s "
    "[%(task_id)s] "
    "%(name)s%(extras)s: %(message)s%(color_stop)s"
)


def GithubPullRequestLog(self):
    return daiquiri.getLogger(
        __name__,
        gh_owner=self.base.user.login,
        gh_repo=self.base.repo.name,
github jd / daiquiri / daiquiri / formatter.py View on Github external
s = super(ExtrasFormatter, self).format(record)
        self.remove_extras(record)
        return s


class ColorExtrasFormatter(ColorFormatter, ExtrasFormatter):
    """Combines functionality of ColorFormatter and ExtrasFormatter."""

    def format(self, record):
        self.add_color(record)
        s = ExtrasFormatter.format(self, record)
        self.remove_color(record)
        return s


TEXT_FORMATTER = ColorExtrasFormatter(fmt=DEFAULT_EXTRAS_FORMAT)
if jsonlogger:
    JSON_FORMATTER = jsonlogger.JsonFormatter()