-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloggers.py
34 lines (26 loc) · 797 Bytes
/
loggers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logging
"""
Logging Levels
DEBUG
INFO
WARNING
ERROR
CRITICAL
"""
logging.basicConfig(level=logging.DEBUG)
handler = logging.FileHandler("mylog.log")
handler.setLevel(logging.INFO)
logging.warning("You have got 20 mails")
logging.critical("All components failed")
logging.info("Information here")
formatter = logging.Formatter("%(levelname)s - %(asctime)s: %(message)s")
handler.setFormatter(formatter)
# ------------------ Creating my own logger ---------------------------------
logger = logging.getLogger("Intermediate Python")
logger.addHandler(handler)
logger.info("Logger Created by me")
logger.critical("Your channel deleted")
logger.log(logging.ERROR, "An error occured")
logger.debug("Debugging your code")
logger.setLevel(logging.DEBUG)
logger.info("IMPORTANT INFORMATION")