# @skypilot/logger

> A utility for flexibly logging & displaying events

Latest version **0.2.0-next.0** (published 2021-06-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @skypilot/logger
pnpm add @skypilot/logger
yarn add @skypilot/logger
bun add @skypilot/logger
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0-next.0 |
| Published | 2021-06-22 |
| First published | 2021-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | William Thorsen |
| Maintainers | williamthorsen |
| Keywords | event, logging, log, tracing |

## Links

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

## 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.2.0-next.0 (latest) — 2021-06-22
- 0.2.0-next.1 (next) — 2021-06-24

## README

# @skypilot/logger

A utility for flexibly tracking & displaying events

---

[![npm stable](https://img.shields.io/npm/v/@skypilot/logger?label=stable)](https://www.npmjs.com/package/@skypilot/logger)
![stable build](https://img.shields.io/github/workflow/status/skypilot-dev/logger/Stable%20release?label=stable%20build)
[![npm next](https://img.shields.io/npm/v/@skypilot/logger/next?label=next)](https://www.npmjs.com/package/@skypilot/logger)
![next build](https://img.shields.io/github/workflow/status/skypilot-dev/logger/Prerelease?branch=next&label=next%20build)
![downloads](https://img.shields.io/npm/dm/@skypilot/logger)
[![license: ISC](https://img.shields.io/badge/license-ISC-blue.svg)](https://opensource.org/licenses/ISC)

## How to install

```console
yarn add @skypilot/logger
```

## How to use

Add events:

```typescript
const log = new EventLog()
log.debug('A debug event')
log.info('An info event')
log.warn('Something you should know')
log.error('Uh-oh')
```

List event messages:

```typescript
log.getMessages()
```

```text
Debug: A debug event
Info: An info event
Warn: Something you should know
Error: Uh-oh
```

List one level of messages:

```typescript
log.getMessages('error')
```

```text
Error: Uh-oh
```

Or access the messages directly:

```typescript
console.log(log.messages.error)
```
```text
Uh-oh
```

Check for errors:

```typescript
console.log(log.hasErrors)
```

```text
true
```

Add data to every event:

```typescript
const log = new EventLog({ initialData: { key: 'Always added' } })
log.info('Event with data', { newKey: 'Added for one event' })
log.getEvents()
```

```json
[
  {
    "level": "info",
    "message": "Event with data",
    "data": { "key": "Always added", "newKey":  "Added for one event" }
  }
]
```

---

More to be added

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