Adding a CMS to Your Flask Web App Transcripts
Chapter: Logging activity
Lecture: Integration with Logbook

Login or purchase this course to watch this video and the rest of the course contents.
0:00 if you go and look the extensive bility section of the marked on sub template just like we created a new database store and said it.
0:08 What we want to do is we want to do the same thing over here. So over this log in section, we're going to say logging thought,
0:17 set log on and give it a log engine. And for the moment, we don't know what to put here, so we're gonna figure out what's going on.
0:28 But it's very much like this one. When a crear class derived from something implements and methods again, the easier way might just be to make a copy.
0:37 So let's call this template log engine, and this is gonna be a longer if we get when we wanted to drive from that class. We don't need these.
0:53 So again, just like before, can implement the abstract methods and always to do to make this work is come along
1:00 and say we're trying to do a verbose message. Where do you want to send it? We're trying to do a trace message. Where do you want to send it?
1:07 So we want to send it the logbook. So communions say This is a logbook log, sub templates, something like that. And then this is super easy.
1:22 First thing we want to do is check. Is this system remember? You can set his logging levels well. Does it want to allow the message?
1:28 And we say that I look using a basement that hearsay. If self don't should log, then we specified a level.
1:36 So the log level from there in what level are we trying to send or trying to send a verbose message? It also wants us to send the text.
1:47 The reason is that if it knows the message is going to send this empty, it's just going to say no,
1:51 actually, don't walk that. But if it should log over both message, What we're gonna do is just say, Log is the logbook and will say,
1:58 There's no verbose, but there's a trace, and that's pretty much as close as we can get. And we're gonna pass the text over.
2:05 That's it. We just do this a few times over here again. This is trace this level, but traces will be gone. It's was info and logbook hasn't imposed.
2:16 We'll just call that one and then we have. Here's and we can just say logbook. Are you Lada has over an error. Here's one. Now, this is great,
2:28 but we do need to set that up back over here. So I said we will create one of these. And this where we're going to you.
2:36 Once I imported there, you need a passage of log level. So logging dot log level and we're setting it to info now.
2:47 Technically, that still works. It does, you know, I said it, but if you're gonna have to pass it here anyway, let's just get rid of this funkiness.
2:57 And then off it goes. I could also do this. Walk down. Ah, log engine, too. Log engine, Something like that. All right, Now, if we run this,
3:07 let's see what we get that in. Mark down luggage into template logger. That was a notice. That's cool. And if we go, I guess you get over this up.
3:18 We go over here and we click on one of the pages that generates something. Notice. Now, the message looks just like our built in one's.
3:27 So we have Ah, daytime. We have a level. So this is info or category is the sub templates.
3:35 And then here's what's happening over there because this is info. If for some reason in the log in section up here, we only wanna have noticing above.
3:48 Now we can go request that out of that page and notice there's no messages because even though the September library would send it,
3:56 the underlying logbook longer says you know it or not, are not sharing those messages. That's too much detail for right now.
4:04 I'll put it back on the phone. Okay, that's it. This is how we put these two things together.
4:10 We can control where the logs go by creating some very simple class like this. Thank you. Itics agree. This is quite quite simple.
4:19 There's not a whole lot going on here and then just plugging it in. Now our whole logging framework is together.
4:26 We get a little bit more information out of the system, not a requirement. But I think if you're doing this in production,
4:31 you probably wanna have some visibility into what's going on in this underlying template engine as


Talk Python's Mastodon Michael Kennedy's Mastodon