This module provides a 'transport' for pino that sends logs to Slack.
yarn install pino-slack-transport
import { createTransport } from 'pino-slack-transport'
// with options defined in pino
export default createTransport
// with options defined in this module
const options = { webhookUrl: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' }
export default function transport() {
return createTransport(options)
}
import { createTransport } from 'pino-slack-transport'
import { pino } from 'pino'
const options = { webhookUrl: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' }
const logger = pino(
pino.transport({
targets: [
// { level: 'error', target: '#pino/file', options: { destination: '/dev/stderr' } },
// { level: 'trace', target: '#pino/file', options: { destination: '/dev/stdout' } },
{ level: 'debug', target: '../lib/logger.mjs', options }
]
})
)
The string key for the 'channel' in the JSON object.
By default, the channel inherits from the associated Slack app configuration.
Default: { 30: '#2EB67D', 40: '#ECB22E', 50: '#E01E5A', 60: '#E01E5A' }
The mapping from level to color.
Default: { hostname: 0, pid: 0 }
The string keys excluded from the JSON object.
The string key for the image URL in the JSON object.
Keep sockets around so they can be used for future requests without having to reestablish a TCP connection.
Default: 'msg'
The string key for the 'message' in the JSON object.
The Incoming Webhook URL.