what I've done to get ValueError in logging module python -


i want write log both file , stdout, hence use code valueerror in stdout not in file.

i want logging info level , above both stdout , file. , debug level , above wrote file.

import logging  logging.basicconfig(level=logging.debug,                     format='%(asctime)s %(name)-12s %(levelname)-8s %(funcname)-5s %(message)s',                     filename='okanimedownloader.log',                     filemode='w')  console = logging.streamhandler() console.setlevel(logging.info) formatter = logging.formatter('%(levelname):-8s %(message)s') console.setformatter(formatter) logging.getlogger('').addhandler(console)    dic = {'google drive': 'https://docs.google.com/file/d/0b-fk-js8djceyvvwrwdfwnc1yws/preview', 'mega': '//vk.com/video_ext.php?oid=359177611&id=456239042&hash=59d982cc2450bc8d&sd', 'openload': 'https://openload.co/embed/mvyskus5rm4/%5bokanime.com%5d_s%40ks2_-_11_%28animok%29.mp4', 'streamango': 'https://streamango.com/embed/pnfdsqnedcffrttm/_okanime_com_s_ks2_-_11_animok_mp4', 'cloudy': 'https://www.cloudy.ec/embed.php?id=09c53285b6ac4', 'tune.pk': 'https://embed.tune.pk/play/7147555/okanimecom-sks2-11-animok', 'mp4upload': 'https://www.mp4upload.com/embed-swz4hesaisnm.html'}  logging.info('the dic:  {}'.format(dic)) 

output:

--- logging error --- traceback (most recent call last):   file "/library/frameworks/python.framework/versions/3.6/lib/python3.6/logging/__init__.py", line 992, in emit     msg = self.format(record)   file "/library/frameworks/python.framework/versions/3.6/lib/python3.6/logging/__init__.py", line 838, in format     return fmt.format(record)   file "/library/frameworks/python.framework/versions/3.6/lib/python3.6/logging/__init__.py", line 578, in format     s = self.formatmessage(record)   file "/library/frameworks/python.framework/versions/3.6/lib/python3.6/logging/__init__.py", line 547, in formatmessage     return self._style.format(record)   file "/library/frameworks/python.framework/versions/3.6/lib/python3.6/logging/__init__.py", line 391, in format     return self._fmt % record.__dict__ valueerror: unsupported format character ':' (0x3a) @ index 12 call stack:   file "/users/hamza/dropbox/my py projects/okanime/testing json.py", line 18, in <module>     logging.info('the dic:  {}'.format(dic)) message: "the dic:  {'google drive': 'https://docs.google.com/file/d/0b-fk-js8djceyvvwrwdfwnc1yws/preview', 'mega': '//vk.com/video_ext.php?oid=359177611&id=456239042&hash=59d982cc2450bc8d&sd', 'openload': 'https://openload.co/embed/mvyskus5rm4/%5bokanime.com%5d_s%40ks2_-_11_%28animok%29.mp4', 'streamango': 'https://streamango.com/embed/pnfdsqnedcffrttm/_okanime_com_s_ks2_-_11_animok_mp4', 'cloudy': 'https://www.cloudy.ec/embed.php?id=09c53285b6ac4', 'tune.pk': 'https://embed.tune.pk/play/7147555/okanimecom-sks2-11-animok', 'mp4upload': 'https://www.mp4upload.com/embed-swz4hesaisnm.html'}" arguments: () 

formatter = logging.formatter('%(levelname)-8s : %(message)s') 

this syntax fix error in formatter


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -