import weblate.logger as LOGGER LOGGER.info('Hello, world!')
import logging.config logging.config.dictConfig({ 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'standard': { 'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s' }, }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'level': 'INFO', 'formatter': 'standard' }, }, 'loggers': { 'weblate': { 'handlers': ['console'], 'level': 'DEBUG', 'propagate': True }, } }) LOGGER.info('Hello, world!')
try: x = 1 / 0 except Exception as e: LOGGER.error('An error occurred: %s', e, exc_info=True)This code will catch an exception and log an error message, including the exception information. Overall, the weblate.logger module provides a convenient and flexible way to log messages in Python applications.