Writing clean code, with good logic is important.
But how about debugging the same like a pro and build pretty graphs?
“Debug like a pro just like you code”
Print statements though easy and powerful don’t help in understanding the behavioral aspects. In order to perform functionalities like visualizing the error/warning rates, we need an advanced debugging tool.
Through my talk, I aim to introduce debugging libraries like “logger”. Logger can be incorporated with Django with a couple of lines of code, which not only helps us understand the errors, but also the possible areas of improvement.
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
stackconf 2020 | Let’s Debug Django like pro by Sayantika Banik
1. Let's Debug
Django like pro
Backend Engineer @Continual Engine
Open source contributor | Mentor | Building tech communities ()
2. AGENDA
Debugging Techniques
What is Logging ?
Print Vs Logger
Deep diving into Logger
Configuring with Django
settings.py
Developing a visualisation using
logger data
Conclusion
5. LOGGING AND
LOGGER
Logging is basically tracking events once
a code/software runs. It is very essential
for debugging your software
Maintaining a log file helps is fixing
crashes faster
Logger is a built-in python module that
allows debugging and recording status
messages
6. Print statements works for
small scale
With Print statements it's
difficult to control the log
information one want to
capture
Cannot map the severity level
with print statements
Cannot map the timestamp
with the message emitted
PRINT VS LOGGER
7. Deep Dive into Logger (04 Pillars)
FILTER
Filters provide a finer grained facility
for determining which log records to
output
LOGGER
A logger is the entry point into the
logging system.
A logger is configured to have a log
level
FORMATTER
Specifies layer/entities of record in
the output
HANDLER
Handler defines the destination of
the log record
For example - To a file, Console
8. MORE ABOUT LOGGER
LEVELS
DEBUG - Information used for debugging purposes
INFO - General message
WARNING - Information used for Minor fault occurrence
ERROR - Information used for Major problem occurrence
CRITICAL - Information used for Critical issue occurrence
9. EXAMPLE USAGE
DEBUG - logger.debug()
INFO - logger.info()
WARNING - logger.warning()
ERROR - logger.error()
CRITICAL - logger.critical()
13. D I F F I C U L T Y
Presentations are
communication tools
that can be used as
demonstrations.
I N T E R E S T
Presentations are
communication tools
that can be used as
demonstrations.
A P P L I C A T I O N
Presentations are
communication tools
that can be used as
demonstrations.
R E T E N T I O N
[18/Apr/2020 21:58:55] INFO [planets.views:19]
['Mercury', 'Venue', 'Earth', 'mars']
Output of logger
Instance of a logger with default
__name__
creating a log
16. GETTING OUR DATA READY
S T O R E D A T A
I N D E S I R E D
F O R M A T
tail -f
/tmp/debug.log
>out.txt
C O N V E R S I O N
To CSV/TSV etc
C H O O S E
T H E D A T A
P O I N T S
B U I L D ( ^ _ ^ )
I N S I G H T F U L
V I S U L I Z A T I O N