# @windingtree/sdk-logger

> Logger

Latest version **1.1.4** (published 2024-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @windingtree/sdk-logger
pnpm add @windingtree/sdk-logger
yarn add @windingtree/sdk-logger
bun add @windingtree/sdk-logger
```

## 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.1.4 |
| Published | 2024-01-17 |
| First published | 2023-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Kostiantyn Smyrnov |
| Maintainers | valera_rozuvan, kostysh, kvakes, tomashq |

## Links

- npm: https://www.npmjs.com/package/@windingtree/sdk-logger
- Repository: https://github.com/windingtree/sdk.git#readme
- Homepage: https://github.com/windingtree/sdk/tree/readme#readme
- Issues: https://github.com/windingtree/sdk/issues
- npm.io page: https://npm.io/package/@windingtree/sdk-logger

## Dependencies (1)

- [debug](https://npm.io/package/debug.md) ^4.3.4

## Recent versions

- 1.1.4 (latest) — 2024-01-17
- 1.1.4-beta.0 (beta) — 2024-01-17
- 1.1.3 — 2023-12-11
- 1.1.2 — 2023-10-31
- 1.1.1 — 2023-10-25
- 1.1.1-beta.0 — 2023-10-25
- 1.1.0 — 2023-07-27
- 1.1.0-beta.3 — 2023-07-27
- 1.1.0-beta.2 — 2023-07-27
- 1.1.0-beta.1 — 2023-07-23
- 1.1.0-beta.0 — 2023-07-23

## README

# @windingtree/sdk-logger

This package is a simple logging utility for Winding Tree SDK based on the [debug](https://www.npmjs.com/package/debug) package. The logger supports multiple logging levels and enables/disables logging for a particular named scope.

## Installation

```bash
pnpm i @windingtree/sdk-logger
```

## Key Concepts

- The logger is enabled for a specific named scope. This allows you to control logging at a granular level and to enable/disable logging for different parts of your application separately.
- The logger supports different log levels. By default, it uses the base log level (equivalent to `debug` in many logging libraries), but it also supports `error` and `trace` levels for logging errors and tracing information, respectively.
- The logger uses string formatters for the log message, similar to `console.log` or `util.format` in Node.js. This makes it easy to interpolate variables into log messages in a safe and consistent way.

## Usage

```typescript
import { createLogger, disable, enable } from '@windingtree/sdk-logger';

const logger = createLogger('my-logger');

logger('Hello, %s!', 'world');
// Output: my-logger Hello, world!

logger.error('An error occurred: %o', new Error('Test error'));
// Output: my-logger:error An error occurred: Error: Test error

logger.trace('Debug trace: %j', { foo: 'bar' });
// Output: my-logger:trace Debug trace: {"foo":"bar"}

disable(); // all loggers are disabled
enable('my-logger'); // logger 'my-logger' is enabled
```

## API

### createLogger(name: string): Logger

Creates a new logger instance with the given name. The returned logger has methods for different log levels.

### enable(name: string): void

Enables logging for the given named scope.

### disable(): string

Disables all logging.

## Testing

```bash
pnpm test
```

## Contributing

[Contribution guidelines](https://windingtree.github.io/sdk/#/docs/contribution)

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