@shagital/adonisjs-logger-slack

1.3.3 • Public • Published

Adonis Logger Slack Slack icon

npm npm (scoped) NPM

Version [for Adonis v4]

This service provider adds Slack as a driver to Adonis Logger.

This repo is based from https://github.com/pirmax/adonis-logger-rollbar

Usage

Installation

  • You can install the package via NPM: npm install @shagital/adonisjs-logger-slack
  • Or with yarn: yarn add @shagital/adonisjs-logger-slack
  • Or with adonis: adonis install @shagital/adonisjs-logger-slack

Registering provider

Make sure to register the provider inside start/app.js file.

const providers = [
  '@shagital/adonisjs-logger-slack/providers/SlackProvider'
]

Add new configuration inside logger module in config/app.js:

transport: 'slack'

slack: {
    name: Env.get('APP_NAME', 'adonis-app'),
    driver: 'slack',
    webhookUrl: Env.get('SLACK_WEBHOOK_URL'),
    level: 'info',
    appStart : false, // whether to create log when app is starting
    logEnv : false // should send env variables when logging
}

That's it! Now you can use Logger that will send data to Slack.

const Logger = use('Logger')

Logger.info('Test message')
Logger.info('Test message', {user}) // to log extra details
Logger.transport('slack').info('this will log using the slack transport') // to specify the transport manually

Env variables

Slack driver relies on single Env variable: SLACK_WEBHOOK_URL=.

Readme

Keywords

Package Sidebar

Install

npm i @shagital/adonisjs-logger-slack

Weekly Downloads

7

Version

1.3.3

License

MIT

Unpacked Size

12.1 kB

Total Files

7

Last publish

Collaborators

  • djunehor