# @sthom/logging-config

> More configurable logging for Javascript/Typescript

Latest version **1.2.1** (published 2020-02-16) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @sthom/logging-config
pnpm add @sthom/logging-config
yarn add @sthom/logging-config
bun add @sthom/logging-config
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2020-02-16 |
| First published | 2020-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stuart Thomson |
| Maintainers | sthom |

## Links

- npm: https://www.npmjs.com/package/@sthom/logging-config
- Repository: https://github.com/s-thom/logging-config
- Homepage: https://github.com/s-thom/logging-config#readme
- Issues: https://github.com/s-thom/logging-config/issues
- npm.io page: https://npm.io/package/@sthom/logging-config

## Recent versions

- 1.2.1 (latest) — 2020-02-16
- 1.2.0 — 2020-02-16
- 1.1.1 — 2020-02-16
- 1.1.0 — 2020-02-16
- 1.0.1 — 2020-02-16

## README

# `@sthom/logging-config`

Logging configuration for Javascript and Typescript.

This exists because the only way to stop my brain from shouting "you need to make a terrible logging library" is to make a terrible logging library.

Using this with React? Have a look at [https://www.npmjs.com/package/@sthom/logging-config-react](https://www.npmjs.com/package/@sthom/logging-config-react).

## Usage

Basic example:

```ts
import Logger from "@sthom/logging-config";

// Create a new logger
const logger = new Logger();

logger.info("Hello world!");
```

With a tag at the start:

```ts
import Logger from "@sthom/logging-config";

const logger = new Logger("MyFile");

logger.info("Hello world!"); // Logs: [MyFile] Hello world!
```

Only error and fatal messages:

```ts
import Logger, {
  DEFAULT_CONFIGURATION,
  LevelDefaults
} from "@sthom/logging-config";

// This is applied over all Loggers that don't have custom configuration given
DEFAULT_CONFIGURATION.setLogLevel(LevelDefaults.ERROR);

const logger = new Logger();
logger.info("Hello world!"); // Not logged
logger.error("Hello world!"); // Is logged
```

Different configuration per Logger:

```ts
import Logger, {
  LoggingConfiguration,
  LevelDefaults
} from "@sthom/logging-config";

const config1 = new LoggingConfiguration(LevelDefaults.INFO);
const config2 = new LoggingConfiguration(LevelDefaults.ERROR);

const logger1 = new Logger(config1);
const logger2 = new Logger(config2);

logger1.info("Hello world!"); // Is logged
logger2.info("Hello world!"); // Not logged
```

## Log levels

The following levels, in order of increasing severity, are available:

- TRACE: `logger.trace`
- DEBUG: `logger.debug`
- INFO: `logger.info`
- WARN: `logger.trace`
- ERROR: `logger.error`
- FATAL: `logger.fatal`

Support for custom levels may come in the future.

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