# runty-logger

> Pure, lightweight, multi-level, flexible logger

Latest version **2.1.0** (published 2018-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install runty-logger
pnpm add runty-logger
yarn add runty-logger
bun add runty-logger
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2018-05-25 |
| First published | 2017-03-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 206.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tiaan du Plessis |
| Maintainers | tiaanduplessis |
| Keywords | logger, log, logging, console, console.log, runty-logger, pure, lightweight, multi-level, colorized |

## Links

- npm: https://www.npmjs.com/package/runty-logger
- Repository: https://github.com/tiaanduplessis/runty-logger
- Issues: https://github.com/tiaanduplessis/runty-logger/issues
- npm.io page: https://npm.io/package/runty-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

- 2.1.0 (latest) — 2018-05-25
- 2.0.0 — 2018-05-25
- 1.1.1 — 2017-04-14
- 1.1.0 — 2017-04-12
- 1.0.1 — 2017-03-19
- 1.0.0 — 2017-03-19

## README

# runty-logger
[![package version](https://img.shields.io/npm/v/runty-logger.svg?style=flat-square)](https://npmjs.org/package/runty-logger)
[![package downloads](https://img.shields.io/npm/dm/runty-logger.svg?style=flat-square)](https://npmjs.org/package/runty-logger)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![package license](https://img.shields.io/npm/l/runty-logger.svg?style=flat-square)](https://npmjs.org/package/runty-logger)
[![make a pull request](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![Greenkeeper badge](https://badges.greenkeeper.io/tiaanduplessis/runty-logger.svg)](https://greenkeeper.io/)

> Pure, lightweight, multi-level, flexible logger

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#License)

## Install

This project uses [node](https://nodejs.org) and [npm](https://www.npmjs.com). 

```sh
$ npm install runty-logger
$ # OR
$ yarn add runty-logger
```

## Usage

```js
const createLogger = require('runty-logger')

// All arguments are optional. Shown with defaults
const log = createLogger({
  level: 'info',
  name: '',
  levels: {
    trace: 10,
    debug: 20,
    info: 30,
    warn: 40,
    error: 50,
    fatal: 60
  },
  // Control how the message is logged
  log: function defaultLog (timestamp, level = '', name) {
    const outputName = name && name.length ? `${name} -` : '-'
    return (message, data = '') => {
      const output = `${timestamp} ${level.toUpperCase().padEnd(5)} ${outputName}`
      console.log(output, message, data)
      return data || message
    }
  }
})

log.trace('a') // will not do anything
log.debug('b') // will not do anything
log.info('c') // 12:37:33 INFO  - c
log.warn('d') // 12:37:33 WARN  - d
log.error('e') // 12:37:33 ERROR - e
log.fatal('f') // 12:37:33 FATAL - f

const someBool = true
const someObject = {foo: 5}

// Returns value provided for cleaning logging
if (log.info('Some bool set:', someBool)) { // 12:37:33 INFO  - Some bool set: true
  log.info('Ran!') // 12:37:33 INFO  - Ran!
}

if (log.info('someObject.foo', someObject.foo) > 1) { // 12:37:33 INFO  - someObject.foo 5
  log.info('Ran!') // 12:37:33 INFO  - Ran!
}

```

## Contribute

1. Fork it and create your feature branch: git checkout -b my-new-feature
2. Commit your changes: git commit -am 'Add some feature'
3. Push to the branch: git push origin my-new-feature 
4. Submit a pull request

## License

MIT

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