Skip to main content

View Logger

ViewLogger is a simple Django app Log view hits over time so that you know who enter this view and when.

Installation

  • Install the package
pip install ViewLogger
pip install unicodecsv
  • Add Application to your project's INSTALLED_APPs
INSTALLED_APPS = (
    '....',
    'ViewLogger',
    )
  • Add ViewLogger.middleware.ViewLoggerMiddleware to your Middleware classes .
MIDDLEWARE_CLASSES = (
    '....',
    'ViewLogger.middleware.ViewLoggerMiddleware',
    )
  • Run Migrations
   python manage.py migrate ViewLogger 

Notes

  • To exempt urls add VIEWLOGGER_EXEMPTED_PATHS to your setting.py
VIEWLOGGER_EXEMPTED_PATHS=["/worker",]
  • To exempt views add VIEWLOGGER_EXEMPTED_VIEWS to your setting.py
VIEWLOGGER_EXEMPTED_VIEWS=["worker",]
  • To exempt parameters add VIEWLOGGER_EXEMPTED_PARAMETER to your setting.py
VIEWLOGGER_EXEMPTED_PARAMETER=["password",]
  • ViewLogger by dafualt log all requests (GET and POST), add VIEWLOGGER_METHODS in your setting.py to log certain method ,
VIEWLOGGER_METHODS=["POST"]
  • Save Request Duration
VIEWLOGGER_SAVE_DURATION = False
  • To archive/load ViewLogger_Log table add VIEWLOGGER_ARCHIVE_DIR to your setting.py
VIEWLOGGER_ARCHIVE_DIR = os.path.join(BASE_DIR, "ViewLoggerArchive")

Then run to archive data

 python manage.py ArchiveViewLoggerTable

you will find JSON file named From_(first date in ViewLogger table)To(last date in ViewLogger table).json file for example : From_2018-01-01_To_2018-12-01.json and the table is empty now and the auto_increment is reset

or run to load the data you have archived from one file

 python manage.py LoadViewLoggerArchivedData.py --file=file_name

or more than one file

 python manage.py LoadViewLoggerTable.py --files="file1_name,file2_name,file3_name"
  • To search in ViewLogger archived files
 python manage.py SearchInViewLoggerArchives --done_by=mahmood --done_on=2018-12-01 

with parameter available with examples :

--done_by=mahmood 
--done_on=date
--url=path/to/view
--view_kwargs=key1=val1,key2=val2,
--view_args=arg1=val1,arg2=val2,
--view_name=view_name
--request_body=key1=val1,key2=val2,
--request_method=GET

the output will generate json object with the values for example :

 File =  From_2018-01-01_To_2018-12-01.json
{
  "view_args": [],
  "view_kwargs": {
    "testid": "40478"
  },
  "request_body": {
    "requestby": "mahmood",
    "resultcode": "1"
  },
  "url": "/path/to/view",
  "done_on": "2018-12-01 12:12:12.142001",
  "view_name": "Edit",
  "done_by": "mahmood",
  "request_method": "POST",
  "id": 498
}

and you can save the putput in file for example :

 python manage.py SearchInViewLoggerArchives --done_by=mahmood --done_on=2018-12-01 > /path/to/output.json

Release files for ViewLogger 2.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ViewLogger 2.2.4
File Size Uploaded
ViewLogger-2.2.4.tar.gz 14.7 kB Details

Release files / ViewLogger-2.2.4.tar.gz

Download URL ViewLogger-2.2.4.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a65d347e7ec6de1e94f021526a90afc8626f9d0c0053068be6501551580b55e4
BLAKE2b-256 checksum
How to use checksums
4dc87138940cba4462699061cb1efeba800bcc1a2e0ade072872a99ef2b84f45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

2.2.4 This release

1 release file

2.2.3

1 release file

2.2.2

2 release files

2.2.1

1 release file

2.2.0

2 release files

2.1.0

1 release file

2.0.0

1 release file

1.8.0

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.0.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page