Redj Log Server
Project 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_typeisjsonorurl, if seturlyou must setresponse_urllikeresponse_url='/error_page'
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'
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Redj LogServer-0.2.0.tar.gz.
File metadata
- Download URL: Redj LogServer-0.2.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a9019e13b5eebfc2ea9d8bb0951246da9a2588368e4c9e5d7e228c415451ff4
|
|
| MD5 |
b078af5e9ff8087e7da8a58f99887d12
|
|
| BLAKE2b-256 |
1511e33f7a3eb0bee8040e73488e5a7ad69914c2b3009e0161aa259b30345738
|
File details
Details for the file Redj_LogServer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: Redj_LogServer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e805c377540714de54e534ac67c75d9a899a120f2215f909a08934a264eb1b56
|
|
| MD5 |
f78933368acb20e62abb9209d520dff3
|
|
| BLAKE2b-256 |
6b56cdecb414d3887651a8475a642da8b7125b17c6dbb32ee3e73a5fccbd0c31
|