Adding a CMS to Your Flask Web App Transcripts
Chapter: Logging activity
Lecture: Adding admin logging
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let's add a little bit of logging using logbook to our admin section. Now, to make things a little bit quicker so you don't watch me type a
0:06
bunch of silly messages I've added a couple of to do's here. So in order to get started,
0:10
we'll just say log is gonna be the logbook lager and we give it a category name. This is gonna be CMS admin or something like that.
0:19
However you want indicated. And then for each one of these, we're gonna go 10 year olds say log dot and to decide the level.
0:28
Somebody viewing this probably there not making any changes. But they are an admin. So it's called this an info and then copy this
0:38
stuff over and drop it in Vienna about email. I am not a user that even in the area, all right, so this will let us log when someone's coming in.
0:48
Let's have a quick look at that. We go over to the admin section and see now CMS admin user is viewing the index Michael at talk Python dot FM.
0:59
We could do that, or we could put the name of the user. I think emails just just good. And then we're going to do that for some of the others.
1:11
So for you in Read Rex, Same pages exactly the same. Say it pages.
1:23
And here it gets a little more interesting because this is where we're making changes, right? We're adding new redirects and so on.
1:28
So let's go down here. Se logged Aunt, is it some kind of thing going on? Probably in notice. There's some kind of they try to submit.
1:37
It Didn't work. Not that are not allowed. Teoh. Just There was some kind of air. So let's record all the errors we send back to users.
1:45
This is going to be VM Don't user email PVM Not air Perfect. And when they've created a redirect successfully, we're going to say something like this,
2:04
and notice is probably good as well. They're making changes, right? All right.
2:13
So users adding a new redirect that's looking good gonna be a very similar over here
2:23
for this instead of add new gonna say at it and a copy this down as well. Edit a redirect and let's just see that this is working real quick.
2:40
We'll go and edit some redirect in a non meaningful way over here. We just say that it go back and look at the output. Over here we have, ah,
2:51
users editing this page, which is going to go there. You would be kind of nicer tohave it like this,
2:57
but not a big deal. And then the usual goes back to view them. Right? Looks like this working.
3:02
I'll go and just finish this out and you'll have it in the code to work