mirror of
https://codeberg.org/prof_x_pvt_ltd/captive.whump.shanti-portal
synced 2024-08-14 22:46:42 +00:00
changed plugin management to simple rq jobs instead of using pkg_resources.
This commit is contained in:
parent
fe5e85f96c
commit
1bf19c791b
13 changed files with 156 additions and 77 deletions
32
plugins/logging.py
Normal file
32
plugins/logging.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
# Demonstration plugin, only logs a message.
|
||||
|
||||
# Sets up logging by importing from the bottle app in the parent dir.
|
||||
from logging import getLogger, DEBUG, WARN, INFO
|
||||
from portal import logHandler, logFormatter
|
||||
|
||||
def run(arg):
|
||||
# The WSGI environ dict should always be there, sans any special objects
|
||||
# like io streams.
|
||||
environ = arg['environ']
|
||||
|
||||
l = getLogger('plugin_logging')
|
||||
l.addHandler(logHandler)
|
||||
l.setLevel(DEBUG)
|
||||
|
||||
log_url = '{proto}://{server}:{port}{request}'.format(
|
||||
proto=environ.get('wsgi.url_scheme'),
|
||||
server=environ.get('SERVER_NAME'),
|
||||
port=environ.get('SERVER_PORT'),
|
||||
request=environ.get('PATH_INFO')
|
||||
)
|
||||
|
||||
log_client = '{client_ip}'.format(
|
||||
client_ip=environ.get('REMOTE_ADDR')
|
||||
)
|
||||
|
||||
# Log a msg
|
||||
l.info('{log_client} - {method} - {log_url}'.format(
|
||||
log_client=log_client,
|
||||
log_url=log_url,
|
||||
method=environ.get('REQUEST_METHOD')
|
||||
))
|
Loading…
Add table
Add a link
Reference in a new issue