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

  Рет қаралды 39,162

Indently

Indently

Күн бұрын

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:
docs.python.org/3/library/log...
▶ Become job-ready with Python:
www.indently.io
▶ Follow me on Instagram:
/ indentlyreels
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

Пікірлер: 45
@arhamsayyed9518
@arhamsayyed9518 Жыл бұрын
A tutorial no one asked for but everyone needed
@untakble
@untakble Жыл бұрын
i agree
@solothebest1850
@solothebest1850 7 күн бұрын
No other way to put it
@higiniofuentes2551
@higiniofuentes2551 Жыл бұрын
For the young developers: the creation of a log file is vital in production to quickly detect/follow any failure!
@SuperVirus1978
@SuperVirus1978 Жыл бұрын
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.
@behnamheydarian9569
@behnamheydarian9569 10 ай бұрын
It will be great if you add real-world examples in your videos. It helps to understand where these modules are used
@littlehuman4860
@littlehuman4860 Жыл бұрын
exactly the tutorial I needed, I heard about logging few days ago and was planning to check it out
@nicflatterie7772
@nicflatterie7772 11 ай бұрын
Well done, to the point, clear, will look for your other videos.
@MrValVet
@MrValVet Жыл бұрын
I love your tutorials. Very well explained. Thanks!
@Indently
@Indently Жыл бұрын
Thank you!
@williamsusa5067
@williamsusa5067 Жыл бұрын
What is the fastest way to learn Python?
@MeiLinFjellstad-oe2cc
@MeiLinFjellstad-oe2cc Жыл бұрын
For me it was learning through books that have interactive content. That way you practice while you learn is easier to remember what you just learned. I learned with: "Programming Not Painfully Boring" for the basics of programming and "Smarter Way to Learn Python".
@gpt.answers
@gpt.answers Жыл бұрын
coding
@user-vb9mv9xb1x
@user-vb9mv9xb1x Ай бұрын
exactly what I need right now, thanks!
@ShehlaGhaffar
@ShehlaGhaffar 3 күн бұрын
Thank you soooooooooo much, it worked all perfectly in the project at work, where we have build an AI chatbot for space sector training solutions.
@Try95th
@Try95th Жыл бұрын
Huh. I've been writing my own logging functions. This might come in handy in the next project. Thanks!
@bozok1903
@bozok1903 Жыл бұрын
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.
@Diegos79
@Diegos79 8 ай бұрын
Excellent teaching. Thanks!
@higiniofuentes2551
@higiniofuentes2551 Жыл бұрын
Thank you for this very useful video!
@FranciscoAntonio-fh1eu
@FranciscoAntonio-fh1eu Жыл бұрын
Thank you very much bro !!!
@kattamaran
@kattamaran Жыл бұрын
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.
@WondrousHello
@WondrousHello Жыл бұрын
Yeah I was gonna say the same. Need to see this properly in action to understand why it’s useful. Seems just like print with extra steps at the moment.
@bygracethroughfaith3213
@bygracethroughfaith3213 7 күн бұрын
Thank you 🥺🥰💕
@kiwiwelch3620
@kiwiwelch3620 Жыл бұрын
I need more of your videos
@martin_460
@martin_460 Жыл бұрын
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.
@mahdimalekifard4038
@mahdimalekifard4038 10 ай бұрын
perfect content
@HitBoxMaster
@HitBoxMaster Жыл бұрын
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
@mariodemarco8973
@mariodemarco8973 Жыл бұрын
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:
@elpiloto100
@elpiloto100 Жыл бұрын
12:30 If you import hello_module before basicConfig, then the configurations passed to basicConfig won't be applied? Does that mean import logging and basicConfig needs be the first and second line in your program everytime?
@elpiloto100
@elpiloto100 Жыл бұрын
Is it possible to raise an error automatically with the logging.error and logging.critical call?
@SolidBuildersInc
@SolidBuildersInc 8 ай бұрын
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
@joelhatsch6618
@joelhatsch6618 Жыл бұрын
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 😀
@sg8nj
@sg8nj 11 ай бұрын
Have doubt: 1. logging.basicConfig can create fille hanlder? . 2. Have created two logging object using logging.basicConfig Is it possible to copy log content from log 1 to log 2. While copy I don't want to copy the timestamp, thread details from log1, need to copy only the content.
@josecintron85
@josecintron85 8 ай бұрын
can you point different log levels to different files?
@yashbhatt2164
@yashbhatt2164 Жыл бұрын
Please Please Pretty Please keep making videos like this. The world needs it. YOU ARE A PERSONAL HERO. 🤗
@iamworstgamer
@iamworstgamer Жыл бұрын
which ide you are using
@manolomonetha8238
@manolomonetha8238 Жыл бұрын
Is there an option for global configuration?
@LiamInviteMelonTeee
@LiamInviteMelonTeee Жыл бұрын
I wonder how many of us watch both your and Mcoding's videos
@RoysIdea
@RoysIdea 3 ай бұрын
Nice video, but why would anyone use such an archaic datetime format in a log file? Just stick to the default
@Anshegar
@Anshegar Жыл бұрын
I think this lib need then you are finish app, and you need ,ake some login temp files, but in dev process print(1) is a GOD XD
@nicenaija9952
@nicenaija9952 Жыл бұрын
Which ide is this
@adityasinha7664
@adityasinha7664 Жыл бұрын
Vs Code
@Jugular1st
@Jugular1st Жыл бұрын
Indently says its PyCharm in the video.
@giovannirossi943
@giovannirossi943 Жыл бұрын
@@adityasinha7664 Nope, it's PyCharm. He's using the new UI (beta)
@VinceKully
@VinceKully 3 ай бұрын
loguru > built-in logging
The FULL Guide To Itertools For Python Developers
29:11
Indently
Рет қаралды 14 М.
Stupid Barry Find Mellstroy in Escape From Prison Challenge
00:29
Garri Creative
Рет қаралды 4,2 МЛН
WHO DO I LOVE MOST?
00:22
dednahype
Рет қаралды 14 МЛН
Эффект Карбонаро и бесконечное пиво
01:00
История одного вокалиста
Рет қаралды 6 МЛН
5 Really Cool Python Functions
19:58
Indently
Рет қаралды 41 М.
Modern Python logging
21:32
mCoding
Рет қаралды 152 М.
The most important Python script I ever wrote
19:58
John Watson Rooney
Рет қаралды 123 М.
5 Useful Python Decorators (ft. Carberra)
14:34
Indently
Рет қаралды 85 М.
PLEASE Use These 5 Python Decorators
20:12
Tech With Tim
Рет қаралды 95 М.
Python logging tutorial: loggers, handlers, and formatters
17:06
Python. Логируем правильно!
23:15
shadrus
Рет қаралды 11 М.
This INCREDIBLE trick will speed up your data processes.
12:54
Rob Mulla
Рет қаралды 256 М.
10 Ways You Can Use "_" In Python (Do you know ALL of them?)
9:56
Stupid Barry Find Mellstroy in Escape From Prison Challenge
00:29
Garri Creative
Рет қаралды 4,2 МЛН