This commit is contained in:
2023-04-29 15:40:31 +02:00
parent acc0f965ff
commit 9f4428cdbc
4 changed files with 60 additions and 7 deletions

4
logging/conf.py Normal file
View File

@@ -0,0 +1,4 @@
import logging
__LOGLEVEL__ = logging.DEBUG

5
logging/test.log Normal file
View File

@@ -0,0 +1,5 @@
2023-04-29 13:11:26,397 [DEBUG] testlogging: DEBUG/Drucken wir vorbereitet
2023-04-29 13:11:26,397 [INFO] testlogging: INFO/Es werden 2 Seiten gedruckt
2023-04-29 13:11:26,397 [WARNING] testlogging: WARN/nicht genügend Papier im Drucker
2023-04-29 13:11:26,397 [ERROR] testlogging: ERROR/Drucker nicht gefunden.
2023-04-29 13:11:26,397 [CRITICAL] testlogging: CRITICAL/Drucker brennt

17
logging/testlogging.py Normal file
View File

@@ -0,0 +1,17 @@
import logging
from conf import __LOGLEVEL__
logging.basicConfig( format='%(asctime)s [%(levelname)s] %(funcName)s: %(message)s',
# filename='test.log',
level=__LOGLEVEL__)
def testlogging():
print('testlogging() aufgerufen.')
logging.debug('DEBUG/Druckdaten werden gesendet.')
logging.info('INFO/Es werden 2 Seiten gedruckt')
logging.warning('WARN/nicht genügend Papier im Drucker')
logging.error('ERROR/Drucker nicht gefunden.')
logging.critical('CRITICAL/Drucker brennt')
if __name__ == '__main__':
testlogging()