diff MoinMoin/util/abuse.py @ 6066:68092d872ecc

add page name to abuse log
author 'Karl O. Pinc' <kop@meme.com>
date Thu, 04 Sep 2014 14:09:28 -0500
parents bbbfb024a967
children 2e0530a78920
line wrap: on
line diff
--- a/MoinMoin/util/abuse.py	Thu Sep 04 13:16:01 2014 -0500
+++ b/MoinMoin/util/abuse.py	Thu Sep 04 14:09:28 2014 -0500
@@ -14,7 +14,7 @@
 logging = log.getLogger(__name__)
 
 
-def log_attempt(system, success, request=None, username=None):
+def log_attempt(system, success, request=None, username=None, page=None):
     """
     log attempts to use <system>, log success / failure / username / ip
 
@@ -23,6 +23,7 @@
     @param success: whether the attempt was successful
     @param request: request object (optional, to determine remote's ip address)
     @param username: user's name (optional, if None: determined from request)
+    @param page: name of the page (optional)
     """
     if username is None:
         if request and hasattr(request, 'user') and request.user.valid:
@@ -30,7 +31,7 @@
         else:
             username = u'anonymous'
     level = (logging.WARNING, logging.INFO)[success]
-    msg = """%s status: %s username: "%s" ip: %s"""
+    msg = """%s status: %s username: "%s" ip: %s page: %s"""
     status = ("failure", "success")[success]
     ip = request and request.remote_addr or 'unknown'
-    logging.log(level, msg, system, status, username, ip)
+    logging.log(level, msg, system, status, username, ip, page)