1.0.0-rc.26 • Published 3 months ago

@exobase/use-logging v1.0.0-rc.26

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

title: 'useLogging' description: 'A hook to log request and response information' group: 'Hooks'

badge: 'Logging'

Provides an Exobase hook that will log information about the request given a string of tokens.

This module inspired by morgan, the logging middleware library for Express.

Install

yarn add @exobase/use-logging
# or
yarn add @exobase/hooks

Import

import { useLogging } from '@exobase/use-logging'
// or
import { useLogging } from '@exobase/hooks'

Usage

import { compose } from 'radash'
import type { Props } from '@exobase/core'
import { useNext } from '@exobase/use-next'
import { useLogging } from '@exobase/use-logging'

export const listLibraries = async (props: Props) => {
  return db.libraries.list()
}

export default compose(
  useNext(),
  useLogging(),
  useLogging('[:method] :path at :date(iso) -> :status in :elapsed(ms'),
  useLogging('[:method] :request-id', {
    format: message => JSON.stringify({ message }),
    logger: console,
    tokens: (l, p, e, r) => ({
      'request-id': () => p.request.headers['x-request-id']
    })
  }),
  listLibraries
)
1.0.0-rc.26

3 months ago

1.0.0-rc.25

3 months ago

1.0.0-rc.24

3 months ago

1.0.0-rc.23

3 months ago

1.0.0-rc.21

1 year ago

1.0.0-rc.20

1 year ago

1.0.0-rc.19

1 year ago

1.0.0-rc.18

1 year ago

1.0.0-rc.17

1 year ago

1.0.0-rc.16

1 year ago

1.0.0-rc.9

1 year ago

1.0.0-rc.7

1 year ago

1.0.0-rc.8

1 year ago

1.0.0-rc.13

1 year ago

1.0.0-rc.12

1 year ago

1.0.0-rc.11

1 year ago

1.0.0-rc.10

1 year ago

1.0.0-rc.15

1 year ago

1.0.0-rc.14

1 year ago

1.0.0-rc.6

1 year ago

1.0.0-rc.5

1 year ago

1.0.0-rc.4

1 year ago

1.0.0-rc.3

1 year ago

1.0.0-rc.2

1 year ago