-
Notifications
You must be signed in to change notification settings - Fork 16
/
1.BasicOfLogging.py
63 lines (50 loc) · 1.97 KB
/
1.BasicOfLogging.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
##------------------------------------------------------------------------------------------------------
#Created By:Ravishankar Chavare
#version:python 3.7
#Date:13/03/2019
#File_des:Introduction of Logging
#Offical Documentation:https://docs.python.org/2/library/logging.html
##------------------------------------------------------------------------------------------------------
'''
Logging is a very useful tool in a programmer’s toolbox.
It can help you develop a better understanding of the flow of a program
and discover scenarios that you might not even have thought of while developing.
Python provides a logging system as a part of its standard library, so you can quickly add logging to your application
Import logging module in python as follow
import logging as log
'''
#importing logging module
import logging as log
'''
Following Are some By Defualt Logging Levels with thier numeric values
CRITICAL 50
ERROR 40
WARNING 30
INFO 20
DEBUG 10
NOTSET 0
'''
#Simple Log Message print on shell
log.debug("This is debug messgae")
log.info("This is info message ")
log.warning("THis is warning Message")
log.error("This is Error Message")
log.critical("This is Critical Message")
'''
When you will run above code then only warning ,error,critical log will run
because python bydefualt logging level set to 30
you can check python logging level using log.root.level
'''
loglevel=log.root.level
print(loglevel)
#logging module shows log from given log to upwards means if we set loglevel =20
#then ppython show info,warning,error,critical logging
#how to change Logging
log.root.level=20 #you must ned to set this when loging imported to apply to all file
print(log.root.level) #here you will get 20 as logger value if you give log now then from 20 to onwards log will show
#After Setting logger value to 20
log.debug("This is debug messgae")
log.info("This is info message ")
log.warning("THis is warning Message")
log.error("This is Error Message")
log.critical("This is Critical Message")