# falalog

> Logs stuff in a nice, consistent way!

Latest version **0.0.6** (published 2015-03-25) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2015-03-25 |
| First published | 2015-03-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | RK |
| Maintainers | karbrowski |

## Links

- npm: https://www.npmjs.com/package/falalog
- Repository: https://github.com/karbroski/falalog
- Issues: https://github.com/karbroski/falalog/issues
- npm.io page: https://npm.io/package/falalog

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^1.0.0

## Recent versions

- 0.0.6 (latest) — 2015-03-25
- 0.0.5 — 2015-03-25
- 0.0.3 — 2015-03-07
- 0.0.2 — 2015-03-07
- 0.0.1 — 2015-03-04

## README

Falalog
===========

Logs stuff in a nice, consistent way!


### Installation
 
```bash
npm install falalog
```


### Usage


```javascript

let falalog = require('falalog');


[{
  name:     'date',                     // name of the field you'll pass in the log object
  coerce:   v => v.toString(),          // function that will coerce the value before logging. optional.
  default:  new Date(2000, 0, 1),       // default value. optional. defaults to a blank string.
  prefix:   '[',                        // printed before the field value in the log line. optional. defaults to [
  suffix:   ']'                         // printed after field value. defaults to ]
}, {
  name:     'name',
  default:  'unknown'                   // note, when a default is non-null, the prefix and suffix will still be printed if a field is not passed
}, {
  name:     'message',
  default:  null                        // choose null for the default to avoid printing prefix/suffix in the event of an unpassed field
}].map(falalog.defineField);




[{
  name: 'debug',                        // here we define what our "log levels" will be. each log object passed must have a level field the name of one of these
  numeric: 0,                           // numeric value associated with log level. logs will not print unless log level exceeds env variable MIN_ERROR_LEVEL
  log: console.log,                     // logging function to use
  objectFilter:  o => o,                // function to filter log object before logging
  stringFilter: s => s,                 // function to filter compiled log string before logging
  styles: ['gray','dim'],                // chalk styles to use on compiled string before logging
},{
  name: 'warning',
  numeric: 2,
  log: console.log,
  styles: ['yellow']
},{
  name: 'error',
  numeric: 3,
  log: console.error,
  styles: ['red']
}].map(falalog.defineLevel);



Falalog.log({
  level:    'debug',
  date:     new Date(2015,0,1),
  name:     'The Dude',
  message:  'Hello, dude!',
  appendStyles: ['bold'] // append the bold style to output
});
// prints "F[debug][Thu Jan 01 2015 00:00:00 GMT-0800 (PST)][The Dude][Hello, Dude!]" to console.log
// note "F[{level}]" will be prepended to all logs, where {level} is the log level


Falalog.log({
  level:    'debug',
  date:     new Date(2015,0,1),
  message:  'Hello, dude!',
  onlyStyles:   ['bold','yellow'] // replace default debug styles with these
});
// prints "F[debug][Thu Jan 01 2015 00:00:00 GMT-0800 (PST)][unknown][Hello, dude!]" to console.log


Falalog.log({
  level:    'debug',
  date:     new Date(2015,0,1),
  stringFilterBefore:   s => s.toUpperCase() // occurs after level string filter
});
// prints "F[DEBUG][THU Jan 01 2015 00:00:00 GMT-0800 (PST)][unknown]" to console.error

/*

Other params for .log():
  stringFilterAfter:   s => s.toUpperCase() // occurs before level string filter
  stringFilterOnly:    s => s.toUpperCase() // bypass level filter with this string filter

*/
```


### Testing

Test cases are incomplete. But:

```bash
cd falalog
mocha --harmony
``

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