-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
basic.ts
33 lines (27 loc) · 832 Bytes
/
basic.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import 'dotenv/config'
import { pino } from 'pino'
import { LokiLogLevel } from '../src/types'
import type { LokiOptions } from '../src/types'
const transport = pino.transport<LokiOptions>({
// 👇 Replace this with "pino-loki"
target: '../dist/index.mjs',
options: {
// These labels will be added to every log
labels: { application: 'MY-APP' },
// custom log levels
levelMap: {
'5': LokiLogLevel.Debug, // Add a custom log level
'10': LokiLogLevel.Info, // Override a default mapping
},
// Credentials for our Loki instance
host: process.env.LOKI_HOST!,
basicAuth: {
username: process.env.LOKI_USERNAME!,
password: process.env.LOKI_PASSWORD!,
},
},
})
const logger = pino(transport)
logger.info('Hello 1!')
logger.warn('Hello 2!')
logger.error('Hello 3!')