# fastlog

> Stupid simple logging for Node.js.

Latest version **1.1.0** (published 2015-03-31) · MIT license · 0 weekly downloads

## Install

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

Provides the command `fastlog`.

## 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.1.0 |
| Published | 2015-03-31 |
| First published | 2013-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Will White |
| Maintainers | willwhite |

## Links

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

## Dependencies (3)

- [split](https://npm.io/package/split.md) ~0.3.1
- [minimist](https://npm.io/package/minimist.md) ^1.1.0
- [underscore](https://npm.io/package/underscore.md) ~1.5.2

## Recent versions

- 1.1.0 (latest) — 2015-03-31
- 1.0.0 — 2014-12-05
- 0.1.0 — 2014-01-23
- 0.0.0 — 2013-10-08

## README

[![Build Status](https://travis-ci.org/willwhite/fastlog.png?branch=master)](https://travis-ci.org/willwhite/fastlog)

fastlog
=======

stupid simple logging for Node.js. Prints messages to stdout.

Create a logger:

```javascript
var logger = require('fastlog')(category, level);
```

`logger` then has a functions named after each of the available log levels.
Levels are (in order of severity) `debug`, `info`, `warn`, `error` and `fatal`.

Both arguments are optional. `category` defaults to to "default" and `level`
defaults to "debug". Anything less severe than the given `level` will not be
logged.

The logger functions take a string (interpolation optional):

```javascript
var logger = require('fastlog')('security', 'debug');
logger.debug('there is a %s in my %s!', 'snake', 'boot');
// [Fri, 05 Dec 2014 02:10:48 GMT] [debug] [security] there is a snake in my boot!
```

Or an Error object. Any string property that's tacked onto the object will
be logged as well:

```javascript
var err = new Error('someone poisoned the water hole!');
err.culprit = 'sid';
logger.error(err);
// [Fri, 05 Dec 2014 02:10:48 GMT] [error] [security] Error: someone poisened the water hole!
//     at Module.runMain (module.js:492:10)
//     at process.startup.processNextTick.process._tickCallback (node.js:244:9)
//     culprit: sid
```

You can format your own prefix as well:
```javascript
var logger = require('fastlog')('configured', 'error', '${level} [${ category }] <${timestamp}>');
logger.error('This town ain\'t big enough for the two of us!');
// error [configured] <Fri, 05 Dec 2014 02:10:48 GMT> This town ain't big enough for the two of us!
```

## Usage via shell scripts

You may also use fastlog in shell scripts. First, make sure fastlog is installed globally
```
npm install -g fastlog
```

**`fastlog <level> [--category=<category>] [message]`**

```sh
> fastlog error --category important "You're my favorite deputy"
# [Fri, 05 Dec 2014 03:17:59 GMT] [error] [important] You're my favorite deputy
```

- Configure verbosity by specifying a `FASTLOG_LEVEL` environment variable.
- Configure your prefix with a `FASTLOG_PREFIX` environment variable.
- Specifying a `category` is optional

```sh
> export FASTLOG_LEVEL=info
> export FASTLOG_PREFIX='<${timestamp}>'
> fastlog debug "I think you've had enough tea for today, let's get you outta here, Buzz."
# (nothing prints)
> fastlog error "I think you've had enough tea for today, let's get you outta here, Buzz."
# <Fri, 05 Dec 2014 03:22:29 GMT> I think you've had enough tea for today, let's get you outta here, Buzz.
```

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