# squeak

> A tiny stream log

Latest version **1.3.0** (published 2015-10-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install squeak
pnpm add squeak
yarn add squeak
bun add squeak
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2015-10-20 |
| First published | 2014-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 54 |
| Author | Kevin Mårtensson |
| Maintainers | kevva |
| Keywords | log |

## Links

- npm: https://www.npmjs.com/package/squeak
- Repository: https://github.com/kevva/squeak
- Homepage: https://github.com/kevva/squeak#readme
- Issues: https://github.com/kevva/squeak/issues
- npm.io page: https://npm.io/package/squeak

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^1.0.0
- [lpad-align](https://npm.io/package/lpad-align.md) ^1.0.1
- [console-stream](https://npm.io/package/console-stream.md) ^0.1.1

## 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

- 1.3.0 (latest) — 2015-10-20
- 1.2.1 — 2015-10-12
- 1.2.0 — 2014-11-24
- 1.1.0 — 2014-11-24
- 1.0.0 — 2014-11-24

## README

# squeak [![Build Status](http://img.shields.io/travis/kevva/squeak.svg?style=flat)](https://travis-ci.org/kevva/squeak)

> A tiny stream log

![](https://cloud.githubusercontent.com/assets/709159/5165451/f0ca124e-73e4-11e4-8a49-9e278b7aff16.png)


## Install

```
$ npm install --save squeak
```


## Usage

```js
var Squeak = require('squeak');
var log = new Squeak()
	.type('info')
	.type('success', {color: 'green'})
	.type('warn', {color: 'yellow'})
	.type('error', {color: 'red'}, function () {
		log.end();
		process.exit(1);
	});

log.info('this is a info message');
log.success('this is a success message');
log.warn('this is a warning');
log.error(new Error('this is an error').stack);

/*
     info : this is a info message
  success : this is a success message
     warn : this is a warning
    error : this is an error
    at ChildProcess.exithandler (child_process.js:648:15)
    at ChildProcess.emit (events.js:98:17)
 */
```

You can also customize the different types to use a custom prefix using the 
`prefix` option:

```js
var Squeak = require('squeak');
var log = new Squeak({separator: ' '})
	.type('success', {color: 'green', prefix: '✔'})
	.type('warn', {color: 'yellow', prefix: '⚠'});

log.success('this is a success message');
log.warn('this is a warning');

/*
  ✔ this is a success message
  ⚠ this is a warning
 */
```


## API

### new Squeak(options)

Creates a new `Squeak` instance.

#### options.align

Type: `boolean`  
Default: `true`

Whether to align the prefixes or not. E.g:

```sh
     foo : hello
  foobar : world
```

#### options.indent

Type: `number`  
Default: `2`

Sets the indentation.

#### options.separator

Type: `string`  
Default: `  :  `

Customize the separator between the `prefix` and the message.

#### options.stream

Type: `stream`  
Default: `process.stderr`

Which `stream` to write to.

### .write(args)

Type: `string`

Writes to `options.stream`, using `process.stderr` by default.

### .writeln(args)

Type: `string`

Same as `.write()` but with a new line.

### .writelpad(args)

Type: `string`

Same as `.write()` but with padding.

### .type(type, options, callback)

Adds a type.

#### type

Type: `string`

The name of the type. Will be used as `prefix` by default.

#### options.color

Type: `string`

Sets the prefix color. Supported colors can be found [here](https://github.com/sindresorhus/ansi-styles#colors).

#### options.prefix

Type: `string`

Sets the `type` prefix. Uses `type` by default.

#### callback

Type: `function`

An optional callback to be called when the `type` is called.

### .emit(event, data)

Emits an event.

### .end(callback)

Type: `function`

Writes a newline and executes an optional callback function.


## License

MIT © [Kevin Mårtensson](https://github.com/kevva)

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