<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def log(host=None, port=None, limit=0):

 """view log of web server"""

    app.config['HOST'] = first_value(host, app.config.get('HOST',None), '0.0.0.0')
    app.config['PORT'] = int(first_value(port, app.config.get('PORT',None), 5001))
    if app.config['HOST'] == "0.0.0.0": 
        host="127.0.0.1"
    else:
        host = app.config['HOST']
    port = app.config['PORT']    
    try:
        res = requests.get('http://%s:%s/api/log?limit=%s' % (host, port, limit))
        if res.status_code == 200:
            for record in json.loads(res.text):
                if record['level'] >= 30:
                    print(record['msg'], file=sys.stderr)
                else:    
                    print(record['msg'], file=sys.stdinfo)
        else:
            print('web server is not flaskserver', file=sys.stderr)
    except:
        print('web server is not flaskserver or not start', file=sys.stderr)