Skip to content

Yandex cloud log formatting changes in 0.142 and above crash info level logs #47

Description

@potiuk

The change #33 broke logging functionality.

Yandexloud 0.142, 0.143, 0.144 and 0.145 are broken.

For example it generates this error:

/usr/local/lib/python3.7/site-packages/yandexcloud/_wrappers/dataproc/__init__.py:466: in create_hive_job
    self.log.info("Running Hive job. Cluster ID: {cluster_id}", cluster_id=cluster_id)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <RootLogger root (INFO)>, msg = 'Running Hive job. Cluster ID: {cluster_id}', args = (), kwargs = {'cluster_id': 'my_cluster_id'}

    def info(self, msg, *args, **kwargs):
        """
        Log 'msg % args' with severity 'INFO'.
    
        To pass exception information, use the keyword argument exc_info with
        a true value, e.g.
    
        logger.info("Houston, we have a %s", "interesting problem", exc_info=1)
        """
        if self.isEnabledFor(INFO):
>           self._log(INFO, msg, args, **kwargs)
E           TypeError: _log() got an unexpected keyword argument 'cluster_id'

/usr/local/lib/python3.7/logging/__init__.py:1378: TypeError
---------------------------------------------------------------------------------

The problem is that Python logging does not support "brace" style logging by default and unless you configure your application, it only supports "%" style logging.

See https://docs.python.org/3/howto/logging-cookbook.html#using-particular-formatting-styles-throughout-your-application

Brace style parameters should not be used in libraries, because you never know how customers of your library will use it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions