我在我的脚本中按如下方式设置了日志记录,但是它没有捕获warning
,debug
或脚本失败并出现TypeError: 'bool' object has no attribute '__getitem__'
### Setup logging
log = os.path.join(os.path.dirname(os.path.realpath(__file__)),'clone.log')
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s %(filename)-15s %(funcName)-20s %(lineno)-5s %(levelname)-8s: %(message)s', datefmt="%Y-%m-%d %H:%M:%S")
ch.setFormatter(formatter)
logger.addHandler(ch)
fh = logging.FileHandler(log, 'w')
fh.setLevel(logging.DEBUG)
fh.setFormatter(formatter)
logger.addHandler(fh)
当前日志:
2018-02-01 10:44:20 cloneradar_keyword.py clone 61
2018-02-01 10:44:24 cloneradar_keyword.py clone 130 INFO : Updating milestone & category
2018-02-01 10:44:24 cloneradar_keyword.py clone 131 INFO : 12
2018-02-01 10:44:24 cloneradar_keyword.py clone 132 INFO : None
2018-02-01 10:44:24 cloneradar_keyword.py clone 61 INFO : Logging into radar
2018-02-01 10:44:24 cloneradar_keyword.py clone 68 INFO : Getting original Radar details
2018-02-01 10:44:28 cloneradar_keyword.py clone 81 INFO : Creating clone
不捕获:
2018-02-01 10:44:28 radar.py _login 98 DEBUG : new_time : 1517510668.06
2018-02-01 10:44:28 radar.py _login 99 DEBUG : Difference : 3.45849394798
2018-02-01 10:44:28 radar.py _login 132 DEBUG : Cookie is still valid...
2018-02-01 10:44:28 radar.py CreateCloneProblem 298 INFO : {"component":{"name":"Resource Meter","version":"Lanai"},"originatorOfClone": true,"reason":"Cloning for automation"}
2018-02-01 10:44:28 radar.py CreateCloneProblem 302 WARNING : Error: Unable to get data. Server came back with:
2018-02-01 10:44:28 radar.py CreateCloneProblem 303 WARNING : {"message":"The component you've selected is closed. There is no follow-on component. A problem cannot be saved to a closed component with no follow-on. Please select a different component.","help":"View documentation at http://radar.apple.com/","title":"Problem Update Failed","status":"400 Bad Request"}
Traceback (most recent call last):
File "./cloneradar_keyword.py", line 181, in <module>
cloneID = clone(user, id)
File "./cloneradar_keyword.py", line 88, in clone
newRadarID = newRadar['id']
TypeError: 'bool' object has no attribute '__getitem__'