I'm going to keep this video short because we are going to talk about loggers now.
So let's go ahead and talk about the loggers.
The loggers are really important.
Majority of the time, we can actually get away just by saying console.log.
But sometimes we need a little bit more information on top of console.log.
Maybe you want to write them into some files for other team to actually analyze that.
And bugs can be a little bit tricky to solve just via the console log in a bigger application.
If you're just getting started, it's okay.
I already have created a video onto the production grade loggers.
It's available on my YouTube channel.
You can watch it by presentation as well, and there are a lot of places by which you can actually watch
it or search it on just YouTube production grade loggers by my name.
So what we're going to use, are we going to set up a production grade logger in this application,
the next one that we're going to create?
No, we are not going to set that one because it consumes a bit more time and we are going to put a
tangent and we'll just walk onto that.
But no, it's not like we are not going to use any kind of logger.
I'll walk you through with one, which is one of my favorite ones for just getting started with application.
It is known as Morgan.
Now Morgan is definitely not a match of what I have discussed in this production grade logger that is
definitely much more of capable of doing a lot of things.
But as you can see in the weekly download, this is like really a lot popular up here and all you got
to do is npm install a morgan and again, yes, it is named after the Dexter CDs in case you are about
that.
So Arthur likes to mention that and usage is really simple.
All you got to do is just require this.
MORGAN And then you can predefined that what kind of things you are looking for that.
So let's just say this is the method that you have defined, which is having a request and response
and somebody is hitting you onto a URL.
Let's just say slash my form.
You want to see that if somebody is hitting me, what kind of ID he is bringing in, what kind of request
he's sending, get request or post request or whatever is coming in.
So in that case, you can actually mention the format string that how you want to see the information,
for example, colon method, URL, status and all that information that you want to check out.
In fact, if you'll go a little bit at the bottom side, notice here they give you all the response
that how you can take it.
So if I scroll it a little bit, yes, I know that's a lot, but I need to scroll a bit more here and
probably a little bit more.
And.
I know this is not, but here it is.
So at the very end of it you can see that this is a complete example of how to use the tokens and everything.
So notice here it says colon ID.
So anything that is coming up as an ID in the URL, we are taking this one.
Then it says the method get post.
What is the URL that is hitting up or you can just replace it via bit with the tiny and it will just
give you basic information.
You can definitely customize that.
As you can see in this whole example, it is really simple to set up the.
Morgan We just require it at the top and then we go ahead and use it as a middleware notice here to
use Morgan and just use the tiny and that's it.
That's all you got to do.
Again, all of your methods, all of your routes that you are defining or controllers that needs to
come after that.
So placing of your Morgan is really important.
So make sure you do that.
And again, this is basically of how the loggers actually work.
And yes, I do agree that even if you don't install Morgan, you'll be absolutely fine.
There is nothing that you'll be missing out.
But I say that, hey, get in a habit of using some kind of loggers.
Maybe Morgan is a great place to get started with, because when you'll be moving into a company which
works on a bit of a scale, then you'll be seeing this production grade logger.
And I don't want you to get freaked out that, Hey, what is this?
I never studied it.
I never understood it.
No, these grader, these production grade loggers are pretty common.
So, again, spend your time a little bit onto this video as well.
It's a nice video, kind of a crash course on using production grade logger, or you can skip it to
watch this Winston video at the very end of the course.
So kind of a right to note that after finishing this course, I'll watch that.
So that's it.
Let's keep it short and move on to the next one.