'Stop Printing, Start Logging!' (Logging Tutorial For Python Developers)

preview_player
Показать описание
Logging is far more powerful than printing in Python. It really gives you a lot of free information, so in this video I will teach you the basics of how you can get started with using the logging module in Python, so that you can create far more detailed logs!

Logrecord Attributes:

▶ Become job-ready with Python:

▶ Follow me on Instagram:

00:00 Intro
00:24 import logging
00:34 What is logging?
00:46 Logging levels
03:39 Log file
04:20 Adding variables
05:50 Creating detailed logs
06:43 Formatting
12:40 Conclusion
Рекомендации по теме
Комментарии
Автор

A tutorial no one asked for but everyone needed

arhamsayyed
Автор

For the young developers: the creation of a log file is vital in production to quickly detect/follow any failure!

higiniofuentes
Автор

Thank you for this video.
There is another reason why you should use the "old" method of string formatting instead of f-strings:
The message string is only expanded/formatted if it is printed/logged - so it will save some procesing power, especially for debug messages which a rarely enabled.
If you use a f-string it will be formatted before it is handed over to the logger - regardles if it is used or not.

SuperVirus
Автор

It will be great if you add real-world examples in your videos.
It helps to understand where these modules are used

behnamheydarian
Автор

Huh. I've been writing my own logging functions. This might come in handy in the next project. Thanks!

Tryth
Автор

Tankyou for the video. It's another very informative and important subject. I have created a user snippet for logging and using it all the time.

bozok
Автор

exactly the tutorial I needed, I heard about logging few days ago and was planning to check it out

littlehuman
Автор

Nice start. Could use a better, real world example. Like combining it with a normal exception you run into and how to log that. Or maybe with a debug example where you try to follow a variable? Is that an example you would use it for in the real world? Im a beginner.. I usually struggle with youtube tutorials because they lack real world examples.

kattamaran
Автор

Well done, to the point, clear, will look for your other videos.

nicflatterie
Автор

I love your tutorials. Very well explained. Thanks!

MrValVet
Автор

exactly what I need right now, thanks!

TiềnLêThanh-du
Автор

What is the fastest way to learn Python?

williamsusa
Автор

Thank you much, it worked all perfectly in the project at work, where we have build an AI chatbot for space sector training solutions.

ShehlaGhaffar
Автор

Are there even people running Python versions pre 3.6, where you don't have f-strings, or even worse, 2.7 where don't have the format() method? A more pertinent question still, why would even be concerned about this kind of backwards compatibility?
Really cool video though. Would've been cool to see real case use though

HitBoxMaster
Автор

AFAIR a classic string formatting ala `log.error("Cant find file %s", filename)` is preferred, so tools and services like Sentry can properly group messages.

martin_
Автор

This was really an awesome share for debugging.

I recently found pdb.

import pdb

Can't recall how to istantiate it but you may get something out of it.

You can put break points and a host of things from the command line.

The 2 of these tools together would be a great thing to have in the tool box for complex applications.

I really like the logging of imported modules.

Breadcrumb Vacuum Cleaner

Kudos

SolidBuildersInc
Автор

Great, already known, that logging lib is there, but this made it more clear. I just wonder if it possible to change config for the level during the code is excuted (e.g. use debug for some new code) while keeping warning for the rest. further, I figured out, that style="{" in the basicconfig enables better formatting like this {asctime:<20}

mariodemarco
Автор

Problem I have is how to handle the log output. either it's too detailed or not enough, or I need different level of detail in different parts of the code etc... ist there a good viewer for the logfile that would maybe thread the output, allowing to collapse/expand the threaded messages. integration in visual studio would be a plus 😀

joelhatsch
Автор

Is it possible to raise an error automatically with the logging.error and logging.critical call?

elpiloto
Автор

Please Please Pretty Please keep making videos like this. The world needs it. YOU ARE A PERSONAL HERO. 🤗

yashbhatt