utils_log.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:motu-client-python 作者: clstoulouse 项目源码 文件源码
def log_url(log, message, url, level = logging.DEBUG ):
    """Nicely logs the given url.

    Print out the url with the first part (protocol, host, port, authority,
    user info, path, ref) and in sequence all the query parameters.

    log: the log into which write the message
    message: a message to print before the url
    url: the url to log
    level: (optional) the log level to use"""

    urls = url.split('?')
    log.log( level, message + urllib2.unquote(urls[0]) )
    if len(urls) > 1:
        for a in sorted(urls[1].split('&')):
            param = a.split('=')
            if( len(param) < 2 ):
              param.append('')
            log.log( level, ' . %s = %s', urllib2.unquote(param[0]), urllib2.unquote(param[1]) )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号