Skip to content

Commit 7f1d4dc

Browse files
committed
fixed cover image for "winston transport"
1 parent a92ecca commit 7f1d4dc

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

content/posts/winston-transports.md

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ tags = ["webdev", "winston", "logging", "custom"]
66
title = "Winston Transports??"
77
[cover]
88
alt = "winston transport blog post cover"
9-
image = "/blog/uploads/Winston Transport Cover.png"
9+
image = "/blog/uploads/winston-transport-cover.png"
1010
+++
1111

1212
### Brief Introduction to what is `winston`?
1313

1414
> Winston is a node package that provides a simple and universal logging library. It supports **multiple transports**, such as file, console, and syslog. Winston is easy to use and can be **customized** to meet your specific needs.
15-
>
1615
1716
Did you see the words `multiple transports` and `customized` in the above definition of `winston` (that I asked Google Bard to write)? Yeah, `winston` is probable the most sophisticated and customizable logger out there.
1817

@@ -21,34 +20,25 @@ Did you see the words `multiple transports` and `customized` in the above defini
2120
So we know that `winston` supports multiple transports, but what is a transport anyway?
2221

2322
> In `winston`, transport is essentially a storage device for your logs. Each instance of a `winston` logger can have multiple transports configured at different levels.
24-
>
2523
2624
So transport is basically like where you want to store your logs.
2725

2826
There are some most basic ones like:
2927

3028
- **The Console**
31-
32-
```tsx
33-
import winston from "winston"
34-
35-
export const logger = winston.createLogger(
36-
{
37-
transports: [
38-
new winston.transports.Console()
39-
],
40-
}
41-
)
42-
```
43-
29+
```tsx
30+
import winston from "winston";
31+
32+
export const logger = winston.createLogger({
33+
transports: [new winston.transports.Console()],
34+
});
35+
```
4436
- **Files**
45-
46-
```tsx
47-
...
48-
new winston.transports.File({ filename: "logs/all.log" })
49-
...
50-
```
51-
37+
```tsx
38+
...
39+
new winston.transports.File({ filename: "logs/all.log" })
40+
...
41+
```
5242

5343
Console and file are like the most basic ones, Console basically prints your logs to the console and file one just stores your log in the defined file. You can go crazy with the options and do a lot more stuff, like storing logs of only a specific `level`, let’s say `error` or something.
5444

@@ -62,7 +52,7 @@ To upload your logs to them, you’ll need custom transport. `winston` give you
6252

6353
So basically custom transports are to upload your logs to some sort of storage or maybe do something else with it, like creating alerts and stuff.
6454

65-
Heres how you create basic custom transport for `winston`:
55+
Here’s how you create basic custom transport for `winston`:
6656

6757
```tsx
6858
// my-transport.ts
File renamed without changes.

0 commit comments

Comments
 (0)