# @timberio/types

> Timber.io - Typescript types

Latest version **0.35.0** (published 2019-08-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install @timberio/types
pnpm add @timberio/types
yarn add @timberio/types
bun add @timberio/types
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.35.0 |
| Published | 2019-08-19 |
| First published | 2018-12-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 44 |
| Author | Lee Benson |
| Maintainers | binarylogic, jszwedko, leebenson, luciofranco, zsherman |
| Keywords | Timber, logging, logger, typescript, types |

## Links

- npm: https://www.npmjs.com/package/@timberio/types
- Repository: https://github.com/timberio/timber-js
- Homepage: https://github.com/timberio/timber-js/tree/master/packages/types#readme
- Issues: https://github.com/timberio/timber-js/issues
- npm.io page: https://npm.io/package/@timberio/types

## Dependencies (1)

- [js](https://npm.io/package/js.md) ^0.1.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.35.0 (latest) — 2019-08-19
- 0.34.2 — 2019-08-19
- 0.34.1 — 2019-06-27
- 0.33.0 — 2019-03-09
- 0.32.0 — 2019-03-09
- 0.31.0 — 2019-03-09
- 0.30.0 — 2019-01-22
- 0.29.0 — 2019-01-22
- 0.28.0 — 2019-01-16
- 0.27.0 — 2019-01-15
- 0.26.0 — 2019-01-15
- 0.25.0 — 2019-01-09
- 0.24.0 — 2019-01-06
- 0.23.0 — 2019-01-06
- 0.22.0 — 2018-12-29
- … 13 more at https://npm.io/package/@timberio/types/versions

## README

# 🌲 Timber - Shared Typescript types

![Beta: Ready for testing](https://img.shields.io/badge/early_release-beta-green.svg)
![Speed: Blazing](https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg)
[![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)

**New to Timber?** [Here's a low-down on logging in Javascript.](https://github.com/timberio/timber-js)

## `@timberio/types`

The Timber JS library packages are written in Typescript.

Various types are shared between multiple packages. Those shared types have been separated out into their own package, to make it easier for importing.

That's what you'll find in this package.

## Importing types

You can import a shared type into a Typescript project by importing directly from this package:

```typescript
// For example, `ITimberLog`
import { ITimberLog } from "@timberio/types";
```

## Types

### `ITimberOptions`

Config options for the Timber [Base class](https://github.com/timberio/timber-js/tree/master/packages/core#the-base-class) for creating a Timber client instance.

```typescript
export interface ITimberOptions {
  /**
   * Endpoint URL for syncing logs with Timber.io
   */
  endpoint: string;

  /**
   * Maximum number of logs to sync in a single request to Timber.io
   */
  batchSize: number;

  /**
   * Max interval (in milliseconds) before a batch of logs proceeds to syncing
   */
  batchInterval: number;

  /**
   * Maximum number of sync requests to make concurrently (useful to limit
   * network I/O)
   */
  syncMax: number;

  /**
   * Boolean to specify whether thrown errors/failed logs should be ignored
   */
  ignoreExceptions: boolean;
}
```

### `LogLevel`

Enum representing a log level between _debug_ -> _error_:

```typescript
enum LogLevel {
  Debug = "debug",
  Info = "info",
  Warn = "warn",
  Error = "error"
}
```

### `Context`

You can add meta information to your logs by adding a `string`, `boolean`, `Date` or `number` to a string field (or any nested object containing fields of the same.)

We call this 'context' and these are the types:

```typescript
/**
 * Context type - a string/number/bool/Date, or a nested object of the same
 */
export type ContextKey = string | number | boolean | Date;
export type Context = { [key: string]: ContextKey | Context };
```

### `ITimberLog`

The log object which is implicitly created by calling `.log()` (or any explicit log level function - e.g. `.info()`), and is passed down the chain for Timber middleware before syncing with [Timber.io](https://timber.io)

```typescript
interface ITimberLog {
  dt: Date;
  level: LogLevel; // <-- see `LogLevel` above
  message: string;
  [key: string]: ContextKey | Context; // <-- see `Context` above
}
```

### `Middleware`

A type representing a [Middleware function](https://github.com/timberio/timber-js/tree/master/packages/core#middleware) passed to `.use()` (or `.remove()`)

```typescript
type Middleware = (log: ITimberLog) => Promise<ITimberLog>;
```

### `Sync`

The type of the function passed to `.setSync()`, for syncing a log with [Timber.io](https://timber.io):

Note: Differs from the `Middleware` type because it receives - and resolves to a Promise of - an array of batched `ITimberLog`.

```typescript
Sync = (logs: ITimberLog[]) => Promise<ITimberLog[]>
```

## LICENSE

[ISC](LICENSE.md)

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