logging python
logging.basicConfig(filename='example.log', filemode='w', level=logging.DEBUG)
logging python
logging.basicConfig(filename='example.log', filemode='w', level=logging.DEBUG)
python logging levels
Logging Levels
CRITICAL
ERROR
WARNING
INFO
DEBUG
NOTSET
testing logging python
# can be done by using unittest's assertLogs
from unittest import TestCase
class MyTest(TestCase):
def test_logs(self):
with self.assertLogs('foo', level='INFO') as cm:
logging.getLogger('foo').info('first message')
logging.getLogger('foo.bar').error('second message')
self.assertEqual(cm.output, ['INFO:foo:first message',
'ERROR:foo.bar:second message'])
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us