How to use the coloredlogs.__init__.UserNameFilter.install function in coloredlogs

To help you get started, weā€™ve selected a few coloredlogs 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 xolox / python-coloredlogs / coloredlogs / __init__.py View on Github external
# Do we need to make %(hostname) available to the formatter?
        HostNameFilter.install(
            fmt=formatter_options['fmt'],
            handler=handler,
            style=style,
            use_chroot=kw.get('use_chroot', True),
        )
        # Do we need to make %(programname) available to the formatter?
        ProgramNameFilter.install(
            fmt=formatter_options['fmt'],
            handler=handler,
            programname=kw.get('programname'),
            style=style,
        )
        # Do we need to make %(username) available to the formatter?
        UserNameFilter.install(
            fmt=formatter_options['fmt'],
            handler=handler,
            username=kw.get('username'),
            style=style,
        )
        # Inject additional formatter arguments specific to ColoredFormatter?
        if use_colors:
            for name, environment_name in (('field_styles', 'COLOREDLOGS_FIELD_STYLES'),
                                           ('level_styles', 'COLOREDLOGS_LEVEL_STYLES')):
                value = kw.get(name)
                if value is None:
                    # If no styles have been specified we'll fall back
                    # to the styles defined by the environment variable.
                    environment_value = os.environ.get(environment_name)
                    if environment_value is not None:
                        value = parse_encoded_styles(environment_value)