# @exobase/use-logging

> Exobase hook to log info about requests

Latest version **1.0.0-rc.27** (published 2024-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @exobase/use-logging
pnpm add @exobase/use-logging
yarn add @exobase/use-logging
bun add @exobase/use-logging
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-rc.27 |
| Published | 2024-07-08 |
| First published | 2022-11-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 40.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | rayepps |
| Maintainers | rayepps |

## Links

- npm: https://www.npmjs.com/package/@exobase/use-logging
- Repository: https://github.com/rayepps/exobase-js
- Homepage: https://github.com/rayepps/exobase-js#readme
- Issues: https://github.com/rayepps/exobase-js/issues
- npm.io page: https://npm.io/package/@exobase/use-logging

## Dependencies (1)

- [@exobase/core](https://npm.io/package/@exobase/core.md) ^1.0.0-rc.31

## Recent versions

- 1.0.0-rc.27 (latest) — 2024-07-08
- 1.0.0-rc.26 — 2024-02-21
- 1.0.0-rc.25 — 2024-02-20
- 1.0.0-rc.24 — 2024-02-19
- 1.0.0-rc.23 — 2024-02-19
- 1.0.0-rc.21 — 2023-03-07
- 1.0.0-rc.20 — 2023-03-02
- 1.0.0-rc.19 — 2023-03-01
- 1.0.0-rc.18 — 2023-03-01
- 1.0.0-rc.17 — 2023-02-22
- 1.0.0-rc.16 — 2023-02-22
- 1.0.0-rc.15 — 2023-01-08
- 1.0.0-rc.14 — 2023-01-07
- 1.0.0-rc.13 — 2023-01-07
- 1.0.0-rc.12 — 2023-01-07
- … 10 more at https://npm.io/package/@exobase/use-logging/versions

## README

---
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](https://github.com/expressjs/morgan), the logging middleware library for Express.

## Install

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

## Import

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

## Usage

```ts
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
)
```

---
_Source: https://npm.io/package/@exobase/use-logging · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
