Robottelo: Define standard for logging

Created on 18 Jul 2016  路  5Comments  路  Source: SatelliteQE/robottelo

Searching on project for "getLogger" you find several modules using it as a modules variable. Some use LOGGER=geLog... and anothers use logger = getLog...

We should use the same name for it and this issue is for discuss, define it and make changes

Most helpful comment

I personally vote for logger lowercase.

  1. Because it is an instance logger = logging.getLogger() it returns an instance of logging.RootLogger, and a custom object instance like that is not immutable as we can add more handlers and formatters to that, so using LOGGER looks like it is a constant which in my view stands better for builtin types and primary type objects.
  2. Because it is the naming used in official documentation https://docs.python.org/3/library/logging.html and other tutorials and references uses lowercase as well http://docs.python-guide.org/en/latest/writing/logging/
  3. Because it is simpler, logger is already the name of logger in other python libraries and frameworks, e.g: in Flask we have app.logger
  4. Because upper case encapsulation and naming mangling is not a common pattern, I do not see too many _SOMETHING even in standard library. (referring to the previous used _LOGGER)
  5. Because, maybe in future (after extensive testing specially in jenkins) we can move to logbook module so we just import logbook as logger logbook takes care of the configuration and module name initialization.

All 5 comments

Particularly I prefer _LOGGER. "_" because it shoul be used only on module's scope. UPPER CASE because once created it should not be chaged.

I personally vote for logger lowercase.

  1. Because it is an instance logger = logging.getLogger() it returns an instance of logging.RootLogger, and a custom object instance like that is not immutable as we can add more handlers and formatters to that, so using LOGGER looks like it is a constant which in my view stands better for builtin types and primary type objects.
  2. Because it is the naming used in official documentation https://docs.python.org/3/library/logging.html and other tutorials and references uses lowercase as well http://docs.python-guide.org/en/latest/writing/logging/
  3. Because it is simpler, logger is already the name of logger in other python libraries and frameworks, e.g: in Flask we have app.logger
  4. Because upper case encapsulation and naming mangling is not a common pattern, I do not see too many _SOMETHING even in standard library. (referring to the previous used _LOGGER)
  5. Because, maybe in future (after extensive testing specially in jenkins) we can move to logbook module so we just import logbook as logger logbook takes care of the configuration and module name initialization.

My vote is for logger = logging.getLogger(__name__) which is a documentation recommendation, namespaces to loggers and make easy to see from what module the message came from.

Have we come to a define standard for this issue?

@SatelliteQE/robottelo-automation I'm giving a +1 to the lowercase.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rochacbruno picture rochacbruno  路  7Comments

renzon picture renzon  路  8Comments

pondrejk picture pondrejk  路  4Comments

rplevka picture rplevka  路  9Comments

renzon picture renzon  路  4Comments