Skip to content

Commit

Permalink
feat: add logger example
Browse files Browse the repository at this point in the history
  • Loading branch information
fletcherist committed Jul 17, 2018
1 parent d4275b4 commit 5411769
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const Alice = require('../dist/index')
const alice = new Alice()

const { loggingMiddleware } = Alice

alice.use(loggingMiddleware({
level: 1 // Optional. DEFAULT 0. see https:/pimterry/loglevel
}))

/* Output:
*
* [21:33:12] INFO root: {messageRecieved} дай совет!
* [21:33:12] INFO root: {messageSent} Make const not var
*/

alice.welcome(async (ctx) => {
ctx.reply('Привет! Смотри, что я могу')
})

alice.command('дай совет', async (ctx) => {
ctx.reply('Make const not var')
})

alice.any(async (ctx) => {
ctx.reply('О чём это вы?')
})

alice.listen('/', 8080)

0 comments on commit 5411769

Please sign in to comment.