# @atp-autoteile/logger

> Library created for logging errors using Sentry and Azure Application Insights.

Latest version **1.0.0** (published 2025-07-31) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install @atp-autoteile/logger
pnpm add @atp-autoteile/logger
yarn add @atp-autoteile/logger
bun add @atp-autoteile/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 | 1.0.0 |
| Published | 2025-07-31 |
| First published | 2022-10-28 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 54.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ATP |
| Maintainers | jannikblume, barbara_kellner, nicolae.visan, chris.tietz, anehaichik |

## Links

- npm: https://www.npmjs.com/package/@atp-autoteile/logger
- Repository: https://github.com/ATPAutoteile/atp-sentry
- Homepage: https://github.com/ATPAutoteile/atp-sentry#readme
- Issues: https://github.com/ATPAutoteile/atp-sentry/issues
- npm.io page: https://npm.io/package/@atp-autoteile/logger

## Dependencies (6)

- [logform](https://npm.io/package/logform.md) ^2.4.2
- [winston](https://npm.io/package/winston.md) ^3.13.0
- [@sentry/node](https://npm.io/package/@sentry/node.md) ^7.1.1
- [winston-transport](https://npm.io/package/winston-transport.md) ^4.7.0
- [applicationinsights](https://npm.io/package/applicationinsights.md) ^2.9.5
- [winston-transport-sentry-node](https://npm.io/package/winston-transport-sentry-node.md) ^2.7.0

## Recent versions

- 1.0.0 (latest) — 2025-07-31
- 0.0.15 — 2024-08-19
- 0.0.14 — 2024-07-18
- 0.0.13 — 2024-04-24
- 0.0.12 — 2024-04-24
- 0.0.11 — 2023-11-01
- 0.0.10 — 2023-09-18
- 0.0.9 — 2023-05-15
- 0.0.8 — 2023-04-27
- 0.0.7 — 2023-01-19
- 0.0.6 — 2022-11-24
- 0.0.5 — 2022-11-09
- 0.0.4 — 2022-11-08
- 0.0.3 — 2022-11-03
- 0.0.2 — 2022-10-28

## README

# ATP_Logger

Library created for logging errors using Sentry and Azure Application Insights.

**! IMPORTANT !**

* Library requires `ATP_LOGGER_DSN` environment variable to log Sentry errors  
* `ATP_LOGGER_ENV` is required for specific Sentry environment (`'production'` by default)  
* `APPLICATIONINSIGHTS_CONNECTION_STRING` is required for Azure Application Insights service  
* Run `npm version <version_name>` after every update  

## Environment Variables Example

```
ATP_LOGGER_DSN='https://******@sentry.io/12345'
ATP_LOGGER_ENV='staging'
APPLICATIONINSIGHTS_CONNECTION_STRING='InstrumentationKey=******;IngestionEndpoint=https://******.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/'
```

## Installation & Basic Usage

Install via npm:

```
npm install @atp-autoteile/logger
```

### For CommonJS:

```js
const { Logger } = require('@atp-autoteile/logger');

const logger = new Logger('my-service');

logger.info('Info message');
```

### For ESM:

```ts
import { Logger } from '@atp-autoteile/logger';

const logger = new Logger('my-service');

logger.info('Info message');
```

## Version Overview

### v0.x (Legacy)

- Basic logger without configuration options in constructor
- Simple logging methods with only the message param

### v1.x (Current)

- Extensive configuration options possible on creation for Azure Application Insights and Sentry, exposes all interfaces of the underlying libraries
- Logging methods offer conditional logging to logging providers as well as custom metadata
- Completely backwards compatible

## Example v1 Configuration

```ts
const logger = new Logger('my-service', {
  azure: {
    aiConfig: { setAutoCollectConsole: [true, true] },
    samplingPercentage: 100
  },
  sentry: {
    sentry: { sampleRate: 0.5, debug: true }
  }
});
```

## Example Logging Method Options

```ts
logger.error(new Error('Payment failed'), {
  logTo: [LoggerProvider.azure], // only send to Azure
  userId: '123',
  cartId: '456',
});
```

## More Information

Full configuration reference and options are available here:  
👉 [ATP Logger Documentation](https://sagdigital.atlassian.net/wiki/spaces/PD/pages/1561428198/ATP+Logger)

---

© ATP Autoteile GmbH

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