# pico-log

> an incerdibly tiny javascript logging library

Latest version **1.0.0** (published 2017-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install pico-log
pnpm add pico-log
yarn add pico-log
bun add pico-log
```

## 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.0.0 |
| Published | 2017-03-16 |
| First published | 2017-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | stolksdorf |
| Maintainers | stolksdorf |
| Keywords | tiny, javascript, node, small, logging, loglevel, pico, logs |

## Links

- npm: https://www.npmjs.com/package/pico-log
- Repository: https://github.com/stolksdorf/pico-log
- Homepage: https://github.com/stolksdorf/pico-log#readme
- Issues: https://github.com/stolksdorf/pico-log/issues
- npm.io page: https://npm.io/package/pico-log

## 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.0.0 (latest) — 2017-03-16

## README

# pico-log
An incredibly tiny javascript logging library.

[![NPM](https://nodei.co/npm/pico-flux.png)](https://nodei.co/npm/pico-log/)

`pico-log` was inspired by the lovely package [`loglevel`](https://www.npmjs.com/package/loglevel). However `loglevel` lacks one key feature, the ability to set your own logging functions. `pico-log` implements the best parts of `loglevel`, with this feature added.


### install

```
npm install --save pico-log
```

### features

- **32 lines of code**
- Log on 5 different levels, `trace`, `debug`, `info`, `warn`, `error`
- Doesn't use wrappers so it maintains stack trace integrity
- Able to overwrite the logging function at each level
- Attempts to use the most appropriate `console` function, falls back onto `console.log`
- Defaults to `warn` level, so if you forget to set a level your production enviroment won't explode with logs



### documentation

#### usage

```
    const log = require('pico-log');
    log.setLevel('info');

    log.debug('Fancy message', false, 6, { nifty : true})
```

#### logging

- `log.trace(arg1, arg2,...)`
- `log.debug(arg1, arg2,...)`
- `log.info(arg1, arg2,...)`
- `log.warn(arg1, arg2,...)`
- `log.error(arg1, arg2,...)`

#### `log.setLevel(level)`

Disable logging below the specified level. `level` can be the following:

- Internal log level, eg. `log.levels.SILENT`
- Case-insenstive string, eg. 'error'
- Numerical index from 0 (trace) to 5 (silent)


#### `log.getLevel()`

Returns the current log level as a number, 0 (trace) to 5 (silent).


#### `log.levels`

Access to `pico-log`s internal log level list, eg. `log.levels.WARN == 3`



#### overwriting log methods

To overwrite a log method, simply assign the function you want to run into the library, eg.

```
    log.debug = (...args)=>{
        console.log('DEBUG', ...args);
    }

    log.debug('test');
```

**Note:** After you overwrite a method, it will log regardless of the level set until `log.setLevel()` is called. `pico-log` caches the logging methods when you set the level and then switches the available methods based on the log level.

If you care about your stacktraces, try not to use wrapper functions when overwriting log methods as best as you can. They will clutter up your stacktraces.

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