Last active
January 23, 2017 01:22
-
-
Save LuqiPan/ae04eb7e0a72c3d1524d3195ef56390e to your computer and use it in GitHub Desktop.
Log Driven Development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def log(log_name, log_fields): | |
"""Log with meta information populated | |
Args: | |
log_name (str): the log name to be written to | |
log_fields (dict): fields that need to be logged | |
Returns: | |
None | |
""" | |
meta_info = { | |
'timestamp': int(time.time()), | |
'ip': get_ip(request), | |
'user_agent': get_user_agent(request), | |
'request_id': get_request_id(request), | |
} | |
log_fields.update(meta_info) | |
logger.log(log_name, log_fields) | |
def login(login, password): | |
# ... | |
if request.POST['VIP_KEY'] == '5fa3e7a21e34714b44720836573a71ce': | |
request.session['is_vip'] = True | |
# log_helper.log method accept | |
log_helper.log('vip_log', {'is_vip': True}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment