WEBVTT

00:03.960 --> 00:08.040
I'm going to keep this video short because we are going to talk about loggers now.

00:08.040 --> 00:10.130
So let's go ahead and talk about the loggers.

00:10.140 --> 00:11.800
The loggers are really important.

00:11.820 --> 00:15.750
Majority of the time, we can actually get away just by saying console.log.

00:15.750 --> 00:19.200
But sometimes we need a little bit more information on top of console.log.

00:19.200 --> 00:23.160
Maybe you want to write them into some files for other team to actually analyze that.

00:23.160 --> 00:27.720
And bugs can be a little bit tricky to solve just via the console log in a bigger application.

00:27.720 --> 00:29.700
If you're just getting started, it's okay.

00:29.790 --> 00:32.880
I already have created a video onto the production grade loggers.

00:32.880 --> 00:34.410
It's available on my YouTube channel.

00:34.410 --> 00:38.790
You can watch it by presentation as well, and there are a lot of places by which you can actually watch

00:38.790 --> 00:42.480
it or search it on just YouTube production grade loggers by my name.

00:42.660 --> 00:47.220
So what we're going to use, are we going to set up a production grade logger in this application,

00:47.220 --> 00:48.810
the next one that we're going to create?

00:48.840 --> 00:53.340
No, we are not going to set that one because it consumes a bit more time and we are going to put a

00:53.340 --> 00:55.320
tangent and we'll just walk onto that.

00:55.320 --> 00:58.260
But no, it's not like we are not going to use any kind of logger.

00:58.260 --> 01:03.060
I'll walk you through with one, which is one of my favorite ones for just getting started with application.

01:03.060 --> 01:04.710
It is known as Morgan.

01:04.710 --> 01:10.140
Now Morgan is definitely not a match of what I have discussed in this production grade logger that is

01:10.140 --> 01:13.830
definitely much more of capable of doing a lot of things.

01:13.830 --> 01:18.600
But as you can see in the weekly download, this is like really a lot popular up here and all you got

01:18.600 --> 01:24.030
to do is npm install a morgan and again, yes, it is named after the Dexter CDs in case you are about

01:24.030 --> 01:24.270
that.

01:24.270 --> 01:27.870
So Arthur likes to mention that and usage is really simple.

01:27.870 --> 01:29.580
All you got to do is just require this.

01:29.580 --> 01:33.540
MORGAN And then you can predefined that what kind of things you are looking for that.

01:33.540 --> 01:37.800
So let's just say this is the method that you have defined, which is having a request and response

01:37.800 --> 01:40.290
and somebody is hitting you onto a URL.

01:40.290 --> 01:41.850
Let's just say slash my form.

01:41.850 --> 01:46.650
You want to see that if somebody is hitting me, what kind of ID he is bringing in, what kind of request

01:46.650 --> 01:49.710
he's sending, get request or post request or whatever is coming in.

01:49.710 --> 01:54.360
So in that case, you can actually mention the format string that how you want to see the information,

01:54.360 --> 01:59.820
for example, colon method, URL, status and all that information that you want to check out.

01:59.850 --> 02:05.130
In fact, if you'll go a little bit at the bottom side, notice here they give you all the response

02:05.130 --> 02:06.180
that how you can take it.

02:06.180 --> 02:12.600
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

02:12.810 --> 02:14.520
probably a little bit more.

02:15.800 --> 02:16.610
And.

02:17.540 --> 02:19.330
I know this is not, but here it is.

02:19.340 --> 02:25.640
So at the very end of it you can see that this is a complete example of how to use the tokens and everything.

02:25.640 --> 02:27.800
So notice here it says colon ID.

02:27.800 --> 02:31.490
So anything that is coming up as an ID in the URL, we are taking this one.

02:31.490 --> 02:33.560
Then it says the method get post.

02:33.560 --> 02:39.350
What is the URL that is hitting up or you can just replace it via bit with the tiny and it will just

02:39.350 --> 02:40.550
give you basic information.

02:40.550 --> 02:42.350
You can definitely customize that.

02:42.380 --> 02:45.350
As you can see in this whole example, it is really simple to set up the.

02:45.350 --> 02:50.900
Morgan We just require it at the top and then we go ahead and use it as a middleware notice here to

02:50.930 --> 02:53.750
use Morgan and just use the tiny and that's it.

02:53.750 --> 02:54.770
That's all you got to do.

02:54.770 --> 02:59.240
Again, all of your methods, all of your routes that you are defining or controllers that needs to

02:59.240 --> 03:00.080
come after that.

03:00.080 --> 03:03.170
So placing of your Morgan is really important.

03:03.170 --> 03:04.460
So make sure you do that.

03:04.460 --> 03:07.580
And again, this is basically of how the loggers actually work.

03:07.580 --> 03:11.810
And yes, I do agree that even if you don't install Morgan, you'll be absolutely fine.

03:11.810 --> 03:13.610
There is nothing that you'll be missing out.

03:13.610 --> 03:17.390
But I say that, hey, get in a habit of using some kind of loggers.

03:17.390 --> 03:21.950
Maybe Morgan is a great place to get started with, because when you'll be moving into a company which

03:21.950 --> 03:25.850
works on a bit of a scale, then you'll be seeing this production grade logger.

03:25.850 --> 03:28.250
And I don't want you to get freaked out that, Hey, what is this?

03:28.250 --> 03:29.180
I never studied it.

03:29.180 --> 03:30.380
I never understood it.

03:30.380 --> 03:33.170
No, these grader, these production grade loggers are pretty common.

03:33.170 --> 03:36.260
So, again, spend your time a little bit onto this video as well.

03:36.260 --> 03:41.510
It's a nice video, kind of a crash course on using production grade logger, or you can skip it to

03:41.510 --> 03:44.240
watch this Winston video at the very end of the course.

03:44.240 --> 03:47.900
So kind of a right to note that after finishing this course, I'll watch that.

03:47.990 --> 03:48.740
So that's it.

03:48.740 --> 03:50.930
Let's keep it short and move on to the next one.
