Skip to main content

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_type is json or url , if set url you must set response_url like response_url='/error_page'

Change Exception response:

redjlog.init(
    ...
    save_response = True
)

Save 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Redj LogServer-0.2.3.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Redj_LogServer-0.2.3-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file Redj LogServer-0.2.3.tar.gz.

File metadata

  • Download URL: Redj LogServer-0.2.3.tar.gz
  • Upload date:
  • Size: 6.7 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

Hashes for Redj LogServer-0.2.3.tar.gz
Algorithm Hash digest
SHA256 1edca73c35ea56d745d57ae3e6e7456eafc3720664aa7e8bba463dce73e1dd0b
MD5 2298b8bf5076611f9af9c68e314317ad
BLAKE2b-256 2f2ca6d3997a9189ee722c01adfe47e34618637baed94cffcd738e64b45c44b1

See more details on using hashes here.

File details

Details for the file Redj_LogServer-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: Redj_LogServer-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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

Hashes for Redj_LogServer-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 85a537ffe8b74160b5e38d5ee7e7d948992e83db87510b6a8aa6f6dd0a5afd5d
MD5 a78d6f2bf507a169e5734720b461c27c
BLAKE2b-256 8b09e3a284af1b930014aa40f19ad46d734586afee9d45f4155870b77decc2d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page