mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-05 16:49:45 +00:00
Adding ciphering to usernames in log, so I can finally take screenshots of the most colorful logs of all time.
This commit is contained in:
parent
2a3226259a
commit
befa6eb26f
2 changed files with 13 additions and 1 deletions
|
@ -49,6 +49,7 @@ LOGIN_URL = '/reader/login'
|
||||||
ADMIN_MEDIA_PREFIX = '/media/admin/'
|
ADMIN_MEDIA_PREFIX = '/media/admin/'
|
||||||
SECRET_KEY = 'YOUR_SECRET_KEY'
|
SECRET_KEY = 'YOUR_SECRET_KEY'
|
||||||
EMAIL_BACKEND = 'django_ses.SESBackend'
|
EMAIL_BACKEND = 'django_ses.SESBackend'
|
||||||
|
CIPHER_USERNAMES = False
|
||||||
|
|
||||||
|
|
||||||
# ===============
|
# ===============
|
||||||
|
|
13
utils/log.py
13
utils/log.py
|
@ -1,6 +1,8 @@
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import string
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
class NullHandler(logging.Handler): #exists in python 3.1
|
class NullHandler(logging.Handler): #exists in python 3.1
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
|
@ -33,7 +35,16 @@ def user(u, msg):
|
||||||
elif 'Opera' in user_agent:
|
elif 'Opera' in user_agent:
|
||||||
platform = 'Opera'
|
platform = 'Opera'
|
||||||
premium = '*' if u.is_authenticated() and u.profile.is_premium else ''
|
premium = '*' if u.is_authenticated() and u.profile.is_premium else ''
|
||||||
info(' ---> [~FB~SN%-6s~SB] [%s%s] %s' % (platform, u, premium, msg))
|
username = cipher(u.__unicode__()) if settings.CIPHER_USERNAMES else u
|
||||||
|
info(' ---> [~FB~SN%-6s~SB] [%s%s] %s' % (platform, username, premium, msg))
|
||||||
|
|
||||||
|
def cipher(msg):
|
||||||
|
shift = len(msg)
|
||||||
|
in_alphabet = unicode(string.ascii_lowercase)
|
||||||
|
out_alphabet = in_alphabet[shift:] + in_alphabet[:shift]
|
||||||
|
translation_table = dict((ord(ic), oc) for ic, oc in zip(in_alphabet, out_alphabet))
|
||||||
|
|
||||||
|
return msg.translate(translation_table)
|
||||||
|
|
||||||
def debug(msg):
|
def debug(msg):
|
||||||
logger = getlogger()
|
logger = getlogger()
|
||||||
|
|
Loading…
Add table
Reference in a new issue