comk_djanog_plugin
comk个人开发的django插件,用于很方便的记录日志、下载日志,以及其他拥有小功能的中间件
现有功能
1. 通用日志记录
先在settings中进行配置:
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'comk_django_plugin.middleware.ErrorLogMiddleware', # 加上这一行,注意,添加的位置是非常重要的,建议添加在 auth 下面 'comk_django_plugin.middleware.RequestLogMiddleware', # 加上这一行,注意,添加的位置是非常重要的,建议添加在 auth 下面 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] import comk_django_plugin LOGGING = comk_django_plugin.auto_update_logsetting() # 可传入各个项目自定义的LOGGING配置,会自动合并,同时生效。- 通过django中间件实现对每个请求进行记录,记录类型有:
记录请求数据和返回数据,并记录在 log/comk_request.log 下。
记录错误日志,并记录在 log/comk_error_traceback.log 下。
记录请求超时日志,并记录在 log/comk_long_response_time.log 下。
2. 日志下载
先在settings中进行配置:
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'comk_django_plugin.apps.ComkDjangoPluginConfig', # 加上这一行 ]然后在在urls.py下加上url配置:
from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', include('comk_django_plugin.urls')), ]这样就可以直接在浏览器上输入地址,打开下载log文件的页面,如下:
http://0.0.0.0:8000/getlog/log_download_html/ 该页面是一个简单的HTML,提供打包下载所有日志文件,以及下载单个日志文件的功能。
3. PublicServer文件
一个简单的通用服务的文件,目的是简化开发代码的书写,日后还会不断添加,使用方法如下:
class OrderQuery(View): """ 查询订单历史,并生成excel文件 """ def post(self, request): ps = PublicServer(request) if not ps.check_login_user(): return ps.return_build_error_response(msg='没有登录用户,请登录')
4. PublicDao文件
一个简单的通用数据库操作的文件,目的是简化开发代码的书写,日后还会不断添加,使用方法如下:
class ModelDao(PublicDao): def __init__(model=Model): super().__init__(model)
Metadata
Release files for comk-django-plugin 1.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| comk_django_plugin-1.4.4.tar.gz | 13.9 kB | Without provenance | Details |
Release files / comk_django_plugin-1.4.4.tar.gz
| Download URL | comk_django_plugin-1.4.4.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e46e5351a5f5b63b581fe01c8bd2731acba81b82803c464de38d1f6c2fd2ff2a
|
|
BLAKE2b-256 checksum How to use checksums |
7c386e13220343f469a681ba654aaac22fd98fa2ad9d17046db98f6e5004a193
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.18.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.6.3
|
Security for comk-django-plugin 1.4.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.