%global _empty_manifest_terminate_build 0 Name: python-loggly-python-handler Version: 1.0.1 Release: 1 Summary: Python logging handler that sends messages to Loggly License: MIT URL: https://github.com/loggly/loggly-python-handler/ Source0: https://mirrors.nju.edu.cn/pypi/web/packages/07/10/4f91745f188334e1269f39afa34bdeace06e4f9b4e959e9ad311c9bef1a3/loggly-python-handler-1.0.1.tar.gz BuildArch: noarch Requires: python3-requests-futures %description A simple Python logging Loggly handler that can be used to send to a Loggly Gen2 https endpoint. Borrowed the extra fields concept from the graypy logging library. Check out Loggly's [Python logging documentation](https://www.loggly.com/docs/python-http/) to learn more. ## Installation Download the repository using pip sudo pip install loggly-python-handler ## Use in python ### Configuration Create a Configuration file python.conf and add HTTPSHandler to Configuration File. [handlers] keys=HTTPSHandler [handler_HTTPSHandler] class=loggly.handlers.HTTPSHandler formatter=jsonFormat args=('https://logs-01.loggly.com/inputs/TOKEN/tag/python','POST') [formatters] keys=jsonFormat [loggers] keys=root [logger_root] handlers=HTTPSHandler level=INFO [formatter_jsonFormat] format={ "loggerName":"%(name)s", "asciTime":"%(asctime)s", "fileName":"%(filename)s", "logRecordCreationTime":"%(created)f", "functionName":"%(funcName)s", "levelNo":"%(levelno)s", "lineNo":"%(lineno)d", "time":"%(msecs)d", "levelName":"%(levelname)s", "message":"%(message)s"} datefmt= ### Use Configuration in python file import logging import logging.config import loggly.handlers logging.config.fileConfig('python.conf') logger = logging.getLogger('myLogger') logger.info('Test log') ## Use in Django ### settings.py LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s' }, 'json': { 'format': '{ "loggerName":"%(name)s", "asciTime":"%(asctime)s", "fileName":"%(filename)s", "logRecordCreationTime":"%(created)f", "functionName":"%(funcName)s", "levelNo":"%(levelno)s", "lineNo":"%(lineno)d", "time":"%(msecs)d", "levelName":"%(levelname)s", "message":"%(message)s"}', }, }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'level': 'DEBUG', 'formatter': 'verbose', }, 'loggly': { 'class': 'loggly.handlers.HTTPSHandler', 'level': 'INFO', 'formatter': 'json', 'url': 'https://logs-01.loggly.com/inputs/TOKEN/tag/python', }, }, 'loggers': { 'django': { 'handlers': ['console', ], 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), }, 'your_app_name': { 'handlers': ['console', 'loggly'], 'level': 'INFO', }, }, } ### views.py import logging logger = logging.getLogger(__name__) def logging_example(request): """logging example """ logger.debug('this is DEBUG message.') logger.info('this is INFO message.') logger.warning('this is WARNING message.') logger.error('this is ERROR message.') logger.critical('this is CRITICAL message.') return Response({}, status=status.HTTP_200_OK) Replace %package -n python3-loggly-python-handler Summary: Python logging handler that sends messages to Loggly Provides: python-loggly-python-handler BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-loggly-python-handler A simple Python logging Loggly handler that can be used to send to a Loggly Gen2 https endpoint. Borrowed the extra fields concept from the graypy logging library. Check out Loggly's [Python logging documentation](https://www.loggly.com/docs/python-http/) to learn more. ## Installation Download the repository using pip sudo pip install loggly-python-handler ## Use in python ### Configuration Create a Configuration file python.conf and add HTTPSHandler to Configuration File. [handlers] keys=HTTPSHandler [handler_HTTPSHandler] class=loggly.handlers.HTTPSHandler formatter=jsonFormat args=('https://logs-01.loggly.com/inputs/TOKEN/tag/python','POST') [formatters] keys=jsonFormat [loggers] keys=root [logger_root] handlers=HTTPSHandler level=INFO [formatter_jsonFormat] format={ "loggerName":"%(name)s", "asciTime":"%(asctime)s", "fileName":"%(filename)s", "logRecordCreationTime":"%(created)f", "functionName":"%(funcName)s", "levelNo":"%(levelno)s", "lineNo":"%(lineno)d", "time":"%(msecs)d", "levelName":"%(levelname)s", "message":"%(message)s"} datefmt= ### Use Configuration in python file import logging import logging.config import loggly.handlers logging.config.fileConfig('python.conf') logger = logging.getLogger('myLogger') logger.info('Test log') ## Use in Django ### settings.py LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s' }, 'json': { 'format': '{ "loggerName":"%(name)s", "asciTime":"%(asctime)s", "fileName":"%(filename)s", "logRecordCreationTime":"%(created)f", "functionName":"%(funcName)s", "levelNo":"%(levelno)s", "lineNo":"%(lineno)d", "time":"%(msecs)d", "levelName":"%(levelname)s", "message":"%(message)s"}', }, }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'level': 'DEBUG', 'formatter': 'verbose', }, 'loggly': { 'class': 'loggly.handlers.HTTPSHandler', 'level': 'INFO', 'formatter': 'json', 'url': 'https://logs-01.loggly.com/inputs/TOKEN/tag/python', }, }, 'loggers': { 'django': { 'handlers': ['console', ], 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), }, 'your_app_name': { 'handlers': ['console', 'loggly'], 'level': 'INFO', }, }, } ### views.py import logging logger = logging.getLogger(__name__) def logging_example(request): """logging example """ logger.debug('this is DEBUG message.') logger.info('this is INFO message.') logger.warning('this is WARNING message.') logger.error('this is ERROR message.') logger.critical('this is CRITICAL message.') return Response({}, status=status.HTTP_200_OK) Replace %package help Summary: Development documents and examples for loggly-python-handler Provides: python3-loggly-python-handler-doc %description help A simple Python logging Loggly handler that can be used to send to a Loggly Gen2 https endpoint. Borrowed the extra fields concept from the graypy logging library. Check out Loggly's [Python logging documentation](https://www.loggly.com/docs/python-http/) to learn more. ## Installation Download the repository using pip sudo pip install loggly-python-handler ## Use in python ### Configuration Create a Configuration file python.conf and add HTTPSHandler to Configuration File. [handlers] keys=HTTPSHandler [handler_HTTPSHandler] class=loggly.handlers.HTTPSHandler formatter=jsonFormat args=('https://logs-01.loggly.com/inputs/TOKEN/tag/python','POST') [formatters] keys=jsonFormat [loggers] keys=root [logger_root] handlers=HTTPSHandler level=INFO [formatter_jsonFormat] format={ "loggerName":"%(name)s", "asciTime":"%(asctime)s", "fileName":"%(filename)s", "logRecordCreationTime":"%(created)f", "functionName":"%(funcName)s", "levelNo":"%(levelno)s", "lineNo":"%(lineno)d", "time":"%(msecs)d", "levelName":"%(levelname)s", "message":"%(message)s"} datefmt= ### Use Configuration in python file import logging import logging.config import loggly.handlers logging.config.fileConfig('python.conf') logger = logging.getLogger('myLogger') logger.info('Test log') ## Use in Django ### settings.py LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s' }, 'json': { 'format': '{ "loggerName":"%(name)s", "asciTime":"%(asctime)s", "fileName":"%(filename)s", "logRecordCreationTime":"%(created)f", "functionName":"%(funcName)s", "levelNo":"%(levelno)s", "lineNo":"%(lineno)d", "time":"%(msecs)d", "levelName":"%(levelname)s", "message":"%(message)s"}', }, }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'level': 'DEBUG', 'formatter': 'verbose', }, 'loggly': { 'class': 'loggly.handlers.HTTPSHandler', 'level': 'INFO', 'formatter': 'json', 'url': 'https://logs-01.loggly.com/inputs/TOKEN/tag/python', }, }, 'loggers': { 'django': { 'handlers': ['console', ], 'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), }, 'your_app_name': { 'handlers': ['console', 'loggly'], 'level': 'INFO', }, }, } ### views.py import logging logger = logging.getLogger(__name__) def logging_example(request): """logging example """ logger.debug('this is DEBUG message.') logger.info('this is INFO message.') logger.warning('this is WARNING message.') logger.error('this is ERROR message.') logger.critical('this is CRITICAL message.') return Response({}, status=status.HTTP_200_OK) Replace %prep %autosetup -n loggly-python-handler-1.0.1 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-loggly-python-handler -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Mon Apr 10 2023 Python_Bot - 1.0.1-1 - Package Spec generated