# @byu-oit/logger

> Default configuration for pino logger

Latest version **2.0.0** (published 2024-10-09) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @byu-oit/logger
pnpm add @byu-oit/logger
yarn add @byu-oit/logger
bun add @byu-oit/logger
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-10-09 |
| First published | 2021-04-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 3 |
| Unpacked size | 20.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Brigham Young University - Office of Information Technology |
| Maintainers | gholl0, mjweather, yoshutch, lehinpm, oscea, stuft2, mhailstone, arasmus8, garygsc, martingarn, snelg, byu-oit-bot |

## Links

- npm: https://www.npmjs.com/package/@byu-oit/logger
- Repository: https://github.com/byu-oit/logger
- Homepage: https://github.com/byu-oit/logger#readme
- Issues: https://github.com/byu-oit/logger/issues
- npm.io page: https://npm.io/package/@byu-oit/logger

## Dependencies (3)

- [pino](https://npm.io/package/pino.md) ^9.3.2
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.3.1
- [pino-http](https://npm.io/package/pino-http.md) ^10.2.0

## Recent versions

- 2.0.0 (latest) — 2024-10-09
- 1.0.1 — 2024-07-27
- 1.0.0 — 2024-07-26
- 0.4.2 — 2023-12-11
- 0.4.1 — 2023-12-11
- 0.4.0 — 2023-04-05
- 0.3.14 — 2021-12-14
- 0.3.13 — 2021-11-19
- 0.3.12 — 2021-09-14
- 0.3.11 — 2021-08-30
- 0.3.10 — 2021-08-30
- 0.3.9 — 2021-08-23
- 0.3.8 — 2021-08-16
- 0.3.7 — 2021-08-16
- 0.3.6 — 2021-08-09
- … 18 more at https://npm.io/package/@byu-oit/logger/versions

## README

# BYU Logger
[![GitHub Release](https://img.shields.io/github/release/byu-oit/logger?style=flat)]()
[![codecov](https://codecov.io/gh/byu-oit/logger/branch/main/graph/badge.svg?token=6kkkOs7yEe)](https://codecov.io/gh/byu-oit/logger)

Creates a [`pino` logger](https://github.com/pinojs/pino) with default settings to match the [CES Application Development logging standards](https://github.com/byu-oit/ces-dev-best-practices/blob/main/adr/application/0006-basic-logging-standards.md).

It will pretty-print logs when run locally, but it will write logs in JSON when deployed (when `NODE_ENV=production`).

## Install

```
npm i @byu-oit/logger
```

## Usage
```typescript
import DefaultLogger from '@byu-oit/logger'

const logger = DefaultLogger()

logger.info('Hello World')
logger.warn('Something weird happened')
logger.error(new Error('Something went wrong!'))
```

<details>
<summary>CommonJS Equivalent</summary>
<p>

```javascript
const { default: DefaultLogger } = require('@byu-oit/logger')

const logger = DefaultLogger()

logger.info('Hello World')
logger.warn('Something weird happened')
logger.error(new Error('Something went wrong!'))
```

</p>
</details>

---

The semantics are slightly different than functions like `console.log()` and `console.error()`.

Namely,
```typescript
console.error('Something went wrong in X:', new Error('the error'))
```
would be roughly equivalent to
```typescript
logger.error(new Error('the error'), 'Something went wrong in X')
```

For more details, see the `pino` documentation [here](https://github.com/pinojs/pino/blob/master/docs/api.md#logger-instance).

## Options

Any [`pino` options](https://github.com/pinojs/pino/blob/master/docs/api.md#options) can be overridden, but for compliance with our logging standards, we recommend sticking to the defaults provided in this package.

### Example of overwriting a default

```typescript
import DefaultLogger from "./logger"

const logger = DefaultLogger({ level: 'trace' })
```

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