 The module of the month this week is logging tree. But first of all, let me talk to you about the logging module. All right, let me just import some stuff. Let's just play around with it, you know, because the docs literally do say just import logging and start logging, right? So, all right, logging.info, I am information. Oh, it doesn't do anything. Okay, well, wait a minute, wait a minute. Logging that error, this is an error. That seems to print something. Okay, I don't know what's something. Okay, let me read the docs a bit. They talk about basic config, right? First, off the bat, there's two things wrong here. If you have a Python module that has the Java sort of naming convention of like lowercase and uppercase letters, you're in dangerous territory. Second of all, any library that starts with like basic config, you're in really dangerous territory. Anyways, all right, I just want to log info from the module, right? How hard could this be? So, let me just say, I want my level to be debugged. Let's keep it as simple as possible. And let me just say I just want to do it the standard out, right? Just as a personal preference. Okay, now I've basic configed it, right? So, let me try my little info thing. This is gonna work, right, right, right? No, oh, okay, okay, okay, okay. Well, visibly, there's something. Maybe I need to get the logger, the root logger, right? There's this root thing appearing. Maybe if I can get it, I can configure it to do what I want, right? So, let me get the root logger, right? Well, it must be called root, right? So, let me get the root logger, and let me configure it. So, I got to set the level to what I want, so it's info. I got to want to add my handler. I've been reading docs a bit more now. And again, the standard out. And if I do this, info, it appears. All right, okay, okay, it might be somewhere. It might be somewhere. All right, all right, let's go. Let's try this, this is gonna be it, this is gonna be it, this is gonna be it. Oh, okay. But also, why did it appear twice? Why did my log message appear? Oh, the screen is cut off, but it appeared twice, right? Once it says, I'm information, and then the root logger with the full thing. This is kinda weird. Okay, so now I really dug in. This is like three hours later. I finally figured out what my problem was. The get logger, the root logger is when you don't pass a name. Now I need to set my level on that. Remove all the previous handlers from it, okay? And finally add my log handler I want. All right, cause I'm special. And now, and now, and now we have our logging message. Oh, this is fun. However, now I wanna find out what the hell happened, right? This is where log tree comes in. Let me try again. Oh yeah, no, sorry, from the module it now logs. Now all these pieces come back to the kingdom. Now I wanna find out what the hell was happening. Import logging tree, right? So you can pip install this module really simply. All right, I'm gonna reduce the screen because it's worth seeing from the left hand. So if I just do login tree dot print out, right? One, there's one function, all you need. What it shows me is all the structure of all the loggers you have installed currently on your system. I used this when I was trying to debug something with some Django logging in a module called Raven for Sentry. Anyways, there's a lot of words. And what it shows you is every logger that's installed, how they're streaming. Formatters are not, and their name. So what you see what I did was the root logger is not called the root logger, it's the empty string. And then I installed another logger called root, which is very confusing. And that's the mistake I made, right? But you see it clearly here. You see where they're streaming to. So it could be, this is just standard out, could be a file somewhere on your server somewhere. And it's all in this hierarchy. He's a really simple one, but if you're a really complex one with different modules installing their own loggers, this is really handy to find out, to figure out and debugging the logging module. So, any questions?