Python for Absolute Beginners Transcripts
Chapter: Reading and writing files in Python
Lecture: For real logging use a real framework

Login or purchase this course to watch this video and the rest of the course contents.
0:00 I want to just emphasize, do not do this for actual logging, use a loggin framework. So, I showed you that example before
0:09 about our file syncing things across the different video servers it's using this thing called Logbook. And Logbook is super cool
0:15 what you do is you create an instance of it and then you say log.info or log.notice, or log.error and then you can set it at a level
0:23 so I only want to see warnings and errors or I want to see notice, warnings, and errors or I want to see everything.
0:28 Show me all the messages depending on what you're doing with your application. And it automatically adds the time
0:33 it automatically rotates the file name for the date so you know it has, like if you said rps.log
0:39 it would be RPS log dash whatever the year, month, day is. It's actually really handy cause these files can get really out of control
0:47 and you usually want to know kind of on this day or that day, what happened. It also puts the messages about the level of the message
0:53 and the origin of the message. This is way better, way more tested than something that you're going to create.
0:58 And remember the login was more to teach you about writing and appending the text files than it was to actually create a login system.
1:04 So use a real one if you're actually going to do that but this ideas you learn from the login example are absolutely applicable to all sorts of files
1:13 that you might work with.


Talk Python's Mastodon Michael Kennedy's Mastodon