Log view hits over time so that you know who enter this view and when.
Project description
# 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
```sh
pip install ViewLogger
```
* Add Application to your project's INSTALLED_APPs
```python
INSTALLED_APPS = (
'....',
'ViewLogger',
)
```
* Add `ViewLogger.middleware.ViewLoggerMiddleware` to your Middleware classes .
```python
MIDDLEWARE_CLASSES = (
'....',
'ViewLogger.middleware.ViewLoggerMiddleware',
)
```
* Run Migrations
```sh
python manage.py migrate ViewLogger
```
#### Notes
* To exempt urls add VIEWLOGGER_EXEMPTED_PATHS to your setting.py
```python
VIEWLOGGER_EXEMPTED_PATHS=["/worker",]
```
* To exempt views add VIEWLOGGER_EXEMPTED_VIEWS to your setting.py
```python
VIEWLOGGER_EXEMPTED_VIEWS=["worker",]
```
* To exempt parameters add VIEWLOGGER_EXEMPTED_PARAMETER to your setting.py
```python
VIEWLOGGER_EXEMPTED_PARAMETER=["password",]
```
* ViewLogger by dafualt log all requests (GET and POST), add VIEWLOGGER_METHODS in your setting.py to log certain method ,
```python
VIEWLOGGER_METHODS=["POST"]
```
* To archive/load ViewLogger_Log table add VIEWLOGGER_ARCHIVE_DIR to your setting.py
```python
VIEWLOGGER_ARCHIVE_DIR = os.path.join(BASE_DIR, "ViewLoggerArchive")
```
Then run to archive data
```python
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
python manage.py LoadViewLoggerArchivedData.py --file=file_name
```
or more than one file
```python
python manage.py LoadViewLoggerTable.py --files="file1_name,file2_name,file3_name"
```
* To search in ViewLogger archived files
```python
python manage.py SearchInViewLoggerArchives --done_by=mahmood --done_on=2018-12-01
```
with parameter available with examples :
```python
--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 :
```json
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
python manage.py SearchInViewLoggerArchives --done_by=mahmood --done_on=2018-12-01 > /path/to/output.json
```
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
```sh
pip install ViewLogger
```
* Add Application to your project's INSTALLED_APPs
```python
INSTALLED_APPS = (
'....',
'ViewLogger',
)
```
* Add `ViewLogger.middleware.ViewLoggerMiddleware` to your Middleware classes .
```python
MIDDLEWARE_CLASSES = (
'....',
'ViewLogger.middleware.ViewLoggerMiddleware',
)
```
* Run Migrations
```sh
python manage.py migrate ViewLogger
```
#### Notes
* To exempt urls add VIEWLOGGER_EXEMPTED_PATHS to your setting.py
```python
VIEWLOGGER_EXEMPTED_PATHS=["/worker",]
```
* To exempt views add VIEWLOGGER_EXEMPTED_VIEWS to your setting.py
```python
VIEWLOGGER_EXEMPTED_VIEWS=["worker",]
```
* To exempt parameters add VIEWLOGGER_EXEMPTED_PARAMETER to your setting.py
```python
VIEWLOGGER_EXEMPTED_PARAMETER=["password",]
```
* ViewLogger by dafualt log all requests (GET and POST), add VIEWLOGGER_METHODS in your setting.py to log certain method ,
```python
VIEWLOGGER_METHODS=["POST"]
```
* To archive/load ViewLogger_Log table add VIEWLOGGER_ARCHIVE_DIR to your setting.py
```python
VIEWLOGGER_ARCHIVE_DIR = os.path.join(BASE_DIR, "ViewLoggerArchive")
```
Then run to archive data
```python
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
python manage.py LoadViewLoggerArchivedData.py --file=file_name
```
or more than one file
```python
python manage.py LoadViewLoggerTable.py --files="file1_name,file2_name,file3_name"
```
* To search in ViewLogger archived files
```python
python manage.py SearchInViewLoggerArchives --done_by=mahmood --done_on=2018-12-01
```
with parameter available with examples :
```python
--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 :
```json
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
python manage.py SearchInViewLoggerArchives --done_by=mahmood --done_on=2018-12-01 > /path/to/output.json
```
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
ViewLogger-1.6.0.tar.gz
(10.7 kB
view details)
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 ViewLogger-1.6.0.tar.gz.
File metadata
- Download URL: ViewLogger-1.6.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f42e691ed52d4ac21d81aa60be815dd4c243881b9eb97c139ce74dc2efdf6e0
|
|
| MD5 |
b2f325b69d74813f89c430ca8d2d10d9
|
|
| BLAKE2b-256 |
e818324a11d9401ed18e056159550f8611b69e3d198243a57f30a535f7321393
|
File details
Details for the file ViewLogger-1.6.0-py2-none-any.whl.
File metadata
- Download URL: ViewLogger-1.6.0-py2-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b456e92019aebc26e83fc828141a60fcffc5a41ef1e0e71fcf45135a053f2e75
|
|
| MD5 |
06cd79d5185b41b60b41d23866d285ee
|
|
| BLAKE2b-256 |
8ab3d51501cf37806f74176dd91048e4d8e92e3eb40ab5a9fe6cb3d1ca09aee2
|