SwiftyBeaver log level: Setting message severity

In this lesson

In this lesson, you will learn about the SwiftyBeaver log level and how that is used by SwiftyBeaver to specify the criticality of each logged message using SwiftyBeaver’s logging API.

Transcript

Tap on time to skip ahead

00:11

Hello everyone! In this lesson I want to talk about SwiftyBeaver logging levels and how that manifests itself when we log messages in our applications and frameworks,

00:25

I’m over here at the SwiftyBeaver GitHub repo. I noticed some handsome fellow here under the contributions for SwiftyBeaver :). The point here is, I’m talking about logging levels for SwiftyBeaver. So here is the definition of SwiftyBeaver’s logging level. You can see that we have five different levels, increasing in severity, starting with .Verbose, .Debug, .Info, .Warning and .Error. I’m also going to look at the API for logging through the SwiftyBeaver class. You’ll notice that we can log at a .Verbose level, a .Debug level, an .Info level, .Warning or .Error and obviously those correspond to the logging level definitions here.

01:34

I’m back over in my AppDelegate and I want to show you how I’m using SwiftyBeaver’s logging API to choose the logging level of each message. So I decided that all of my application lifecycle logging statements are going to be logged at the .Verbose level. That means it’s the absolute lowest level possible in SwiftyBeaver. And that’s because they are probably the least important messages that are being logged. However, I’m logging because A) I log everything and B) I may want to actually see those at some point. If I scroll down here, you’ll notice that I’m logging at the .Info level. And in some other cases in my dynamic frameworks, I’m actually logging errors or warnings. So when you log your statements, you need to choose the importance or the criticality of the statement that you’re logging and use the appropriate SwiftyBeaver logging API to properly tag each message as a specific logging level. If you do that, you’ll make it a lot easier to be able to cut out the noise in your application when you’re logging all of these statements all over the place. But, you’ll also be able to see those statements whenever it’s necessary.