diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-18 04:33:12 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-18 04:33:12 +0000 |
| commit | 37d09eca49ca21e6a67a72f01aa399da05f5e5e7 (patch) | |
| tree | 69b2e6289116ad852e944eda63931e6423b2c599 | |
| parent | b543e9ad36c578c972464ab890eaf78fdfa2cead (diff) | |
automatic import of python-redj-logserver
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-redj-logserver.spec | 577 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 579 insertions, 0 deletions
@@ -0,0 +1 @@ +/Redj%20LogServer-0.2.6.tar.gz diff --git a/python-redj-logserver.spec b/python-redj-logserver.spec new file mode 100644 index 0000000..cc3f606 --- /dev/null +++ b/python-redj-logserver.spec @@ -0,0 +1,577 @@ +%global _empty_manifest_terminate_build 0 +Name: python-Redj-LogServer +Version: 0.2.6 +Release: 1 +Summary: Redj Log Server +License: MIT License +URL: https://redj.ai/ +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/76/d3/5621773b9e0dd3311fcc5653577a804afa1903c83598b268ac8e75268d61/Redj%20LogServer-0.2.6.tar.gz +BuildArch: noarch + +Requires: python3-requests + +%description +# Redj Log Server + +## Getting Started + +> in `setting.py`: + +``` +DEBUG = False +``` + +> add code to project(for example add to `url.py`): + +``` +import redjlog + +redjlog.init( + debug=True, + response_type='json', + api_key='YOUR_API_KEY', + server_url='YOUR_SERVER_URL', + project_key='YOUR_PROJECT_ID', +) +``` + +> `response_type` is `json` or `url` , if set `url` you must set `response_url` like `response_url='/error_page'` + +## Save response: + +``` +redjlog.init( + ... + save_response = True, #=> save all response + save_response_exception = True, #=> save exception response +) +``` + +## Change Exception response: + +``` +redjlog.init( + ... + status_key = "your_status_key", + message_key = "your_message_key" +) +``` + +## Usage + +### 1- Log Request + +> in file `settings.py` : + +``` +MIDDLEWARE = [ + ... + 'redjlog.middleware.RequestLog.Base' +] +``` + +### 2- Log Exception + +> in file `settings.py` : + +``` +MIDDLEWARE = [ + 'redjlog.exception.ExceptionHandler.Base', + ... +] +``` + +> in `url.py`: + +``` +from django.conf.urls import handler400, handler403, handler404, handler500 + +handler400 = 'redjlog.exception.HttpException.handler400' +handler403 = 'redjlog.exception.HttpException.handler403' +handler404 = 'redjlog.exception.HttpException.handler404' +handler500 = 'redjlog.exception.HttpException.handler500' +``` + +> in try/except: + +``` +import redjlog + +try: + int('test') +except Exception as ex: + redjlog.catch(ex) +``` + +### 3- Log Exception Knox + +> if install django-rest-knox + +> in file `settings.py` : + +``` +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': [ + 'redjlog.exception.KnoxException.Authentication', + ] +} +``` + +## Exception Handling + +> Redj Logserver uses exceptions for flow control. Meaning, instead of writing too many conditionals, we prefer raising exceptions and then handle them to return an appropriate response. For example: + +``` +import redjlog + +if not request.user.is_authenticated: + raise redjlog.AuthException() +``` + +OR + +``` +import redjlog + +if(!serializer.is_valid()): + raise redjlog.ValidatorException() +``` + +List of Exception + +``` +PayException +DateException +AuthException +OtherException +UploadException +BlockIpException +NotFoundException +ValidatorException +DuplicateException +PermissionException +``` + +for send custom massage user `OtherException`: + +``` +raise OtherException('custom massage for send') +``` + +You can change the exception message + +exceptionMessage input is optional + +``` +import redjlog + +redjlog.exceptionMessage( + auth_massage='Your Massage', + date_massage='Your Massage', + block_massage='Your Massage', + other_massage='Your Massage', + upload_massage='Your Massage', + duplicate_massage='Your Massage', + validator_massage='Your Massage', + not_found_massage='Your Massage', + permission_massage='Your Massage' +) +``` + + + + +%package -n python3-Redj-LogServer +Summary: Redj Log Server +Provides: python-Redj-LogServer +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-Redj-LogServer +# Redj Log Server + +## Getting Started + +> in `setting.py`: + +``` +DEBUG = False +``` + +> add code to project(for example add to `url.py`): + +``` +import redjlog + +redjlog.init( + debug=True, + response_type='json', + api_key='YOUR_API_KEY', + server_url='YOUR_SERVER_URL', + project_key='YOUR_PROJECT_ID', +) +``` + +> `response_type` is `json` or `url` , if set `url` you must set `response_url` like `response_url='/error_page'` + +## Save response: + +``` +redjlog.init( + ... + save_response = True, #=> save all response + save_response_exception = True, #=> save exception response +) +``` + +## Change Exception response: + +``` +redjlog.init( + ... + status_key = "your_status_key", + message_key = "your_message_key" +) +``` + +## Usage + +### 1- Log Request + +> in file `settings.py` : + +``` +MIDDLEWARE = [ + ... + 'redjlog.middleware.RequestLog.Base' +] +``` + +### 2- Log Exception + +> in file `settings.py` : + +``` +MIDDLEWARE = [ + 'redjlog.exception.ExceptionHandler.Base', + ... +] +``` + +> in `url.py`: + +``` +from django.conf.urls import handler400, handler403, handler404, handler500 + +handler400 = 'redjlog.exception.HttpException.handler400' +handler403 = 'redjlog.exception.HttpException.handler403' +handler404 = 'redjlog.exception.HttpException.handler404' +handler500 = 'redjlog.exception.HttpException.handler500' +``` + +> in try/except: + +``` +import redjlog + +try: + int('test') +except Exception as ex: + redjlog.catch(ex) +``` + +### 3- Log Exception Knox + +> if install django-rest-knox + +> in file `settings.py` : + +``` +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': [ + 'redjlog.exception.KnoxException.Authentication', + ] +} +``` + +## Exception Handling + +> Redj Logserver uses exceptions for flow control. Meaning, instead of writing too many conditionals, we prefer raising exceptions and then handle them to return an appropriate response. For example: + +``` +import redjlog + +if not request.user.is_authenticated: + raise redjlog.AuthException() +``` + +OR + +``` +import redjlog + +if(!serializer.is_valid()): + raise redjlog.ValidatorException() +``` + +List of Exception + +``` +PayException +DateException +AuthException +OtherException +UploadException +BlockIpException +NotFoundException +ValidatorException +DuplicateException +PermissionException +``` + +for send custom massage user `OtherException`: + +``` +raise OtherException('custom massage for send') +``` + +You can change the exception message + +exceptionMessage input is optional + +``` +import redjlog + +redjlog.exceptionMessage( + auth_massage='Your Massage', + date_massage='Your Massage', + block_massage='Your Massage', + other_massage='Your Massage', + upload_massage='Your Massage', + duplicate_massage='Your Massage', + validator_massage='Your Massage', + not_found_massage='Your Massage', + permission_massage='Your Massage' +) +``` + + + + +%package help +Summary: Development documents and examples for Redj-LogServer +Provides: python3-Redj-LogServer-doc +%description help +# Redj Log Server + +## Getting Started + +> in `setting.py`: + +``` +DEBUG = False +``` + +> add code to project(for example add to `url.py`): + +``` +import redjlog + +redjlog.init( + debug=True, + response_type='json', + api_key='YOUR_API_KEY', + server_url='YOUR_SERVER_URL', + project_key='YOUR_PROJECT_ID', +) +``` + +> `response_type` is `json` or `url` , if set `url` you must set `response_url` like `response_url='/error_page'` + +## Save response: + +``` +redjlog.init( + ... + save_response = True, #=> save all response + save_response_exception = True, #=> save exception response +) +``` + +## Change Exception response: + +``` +redjlog.init( + ... + status_key = "your_status_key", + message_key = "your_message_key" +) +``` + +## Usage + +### 1- Log Request + +> in file `settings.py` : + +``` +MIDDLEWARE = [ + ... + 'redjlog.middleware.RequestLog.Base' +] +``` + +### 2- Log Exception + +> in file `settings.py` : + +``` +MIDDLEWARE = [ + 'redjlog.exception.ExceptionHandler.Base', + ... +] +``` + +> in `url.py`: + +``` +from django.conf.urls import handler400, handler403, handler404, handler500 + +handler400 = 'redjlog.exception.HttpException.handler400' +handler403 = 'redjlog.exception.HttpException.handler403' +handler404 = 'redjlog.exception.HttpException.handler404' +handler500 = 'redjlog.exception.HttpException.handler500' +``` + +> in try/except: + +``` +import redjlog + +try: + int('test') +except Exception as ex: + redjlog.catch(ex) +``` + +### 3- Log Exception Knox + +> if install django-rest-knox + +> in file `settings.py` : + +``` +REST_FRAMEWORK = { + 'DEFAULT_AUTHENTICATION_CLASSES': [ + 'redjlog.exception.KnoxException.Authentication', + ] +} +``` + +## Exception Handling + +> Redj Logserver uses exceptions for flow control. Meaning, instead of writing too many conditionals, we prefer raising exceptions and then handle them to return an appropriate response. For example: + +``` +import redjlog + +if not request.user.is_authenticated: + raise redjlog.AuthException() +``` + +OR + +``` +import redjlog + +if(!serializer.is_valid()): + raise redjlog.ValidatorException() +``` + +List of Exception + +``` +PayException +DateException +AuthException +OtherException +UploadException +BlockIpException +NotFoundException +ValidatorException +DuplicateException +PermissionException +``` + +for send custom massage user `OtherException`: + +``` +raise OtherException('custom massage for send') +``` + +You can change the exception message + +exceptionMessage input is optional + +``` +import redjlog + +redjlog.exceptionMessage( + auth_massage='Your Massage', + date_massage='Your Massage', + block_massage='Your Massage', + other_massage='Your Massage', + upload_massage='Your Massage', + duplicate_massage='Your Massage', + validator_massage='Your Massage', + not_found_massage='Your Massage', + permission_massage='Your Massage' +) +``` + + + + +%prep +%autosetup -n Redj-LogServer-0.2.6 + +%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-Redj-LogServer -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.6-1 +- Package Spec generated @@ -0,0 +1 @@ +0efe91f94c8c46b33b4f15957db70ba9 Redj%20LogServer-0.2.6.tar.gz |
