# logly

> A minimal logging utility to support verbose and debug modes

Latest version **1.4.1** (published 2015-06-26) · 0 weekly downloads

## Install

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

## 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.4.1 |
| Published | 2015-06-26 |
| First published | 2011-07-02 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=v0.4.8 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Tristan Slominski |
| Maintainers | tristanls |

## Links

- npm: https://www.npmjs.com/package/logly
- Repository: http://github.com/tristanls/logly
- Homepage: https://github.com/tristanls/logly
- Issues: http://github.com/tristanls/logly/issues
- npm.io page: https://npm.io/package/logly

## Recent versions

- 1.4.1 (latest) — 2015-06-26
- 1.4.0 — 2015-06-26
- 1.3.0 — 2012-08-23
- 1.2.0 — 2012-06-13
- 1.1.1 — 2011-08-10
- 1.1.0 — 2011-08-10
- 1.0.1 — 2011-07-02

## README

logly
====

`logly` is a small logging framework in the `nodejs` ecosystem that also allows one to set `debug` or `verbose` logging modes.
It is useful to replace comments that describe what the code is doing, especially in `debug` mode.

## Usage

```javascript
var logly = require( 'logly' );

logly.name( 'myapp' );
logly.mode( 'debug' );

logly.debug( 'debug log' );
// stdout: myapp[debug]: debug log

logly.verbose( 'verbose log' );
// stdout: myapp[verbose]: verbose log

logly.log( 'standard log' );
// stdout: myapp: standard log

logly.warn( 'warning log' );
// stderr: myapp[warn]: warning log

logly.error( 'error log' );
// stderr: myapp[error]: error log

logly.stdout( 'stdout log' );
// stdout: stdout log
// *above does not include 'myapp'

logly.stderr( 'stderr log' );
// stderr: stderr log
// *above does not include 'myapp'
```

### functions as input

`logly` also accepts functions as input; this is primarily to conditionally produce a debug output of complex something if in `debug` mode, for example:

```javascript
var options = { debug: true, output: "some.file" }
// dump options in debug mode
logly.debug( function() {
  for ( var i = 0; i < options.length; i++ ) {
    logly.debug( '[OPTION] ' + option + ": " + options[ option ] );
  }
});
// stdout: myapp[debug]: [OPTION] debug: true
// stdout: myapp[debug]: [OPTION] output: some.file
```

## Options

### color/colour

If you want color then you can enable it (by default color is disabled):

```javascript
logly.options( { color : true } );
```

You can also use `color` or `colour` functions (maintained for backward compatibility):

```javascript
logly.color(true);
logly.colour(true);
```

### date

You can include a date prefix as well:

```javascript
logly.options( { date : true } );
logly.log( 'with date' );
// stdout: Wed Aug 22 2012 21:22:52 GMT-0500 (CDT) myapp: with date
```

[ISO8601](http://en.wikipedia.org/wiki/ISO_8601) format is also available:

```javascript
logly.options( { date : 'iso' } ); // or 'ISO8601', 'iso8601', 'ISO'
logly.log( 'with iso date' );
// stdout: 2012-08-23T02:26:14.841Z myapp: with iso date
```

### processors

You can do string processing:

```javascript
var processors = [];
processors.push( function( input ) {
    return input.replace(/\n/g, ' '); // replace newlines with spaces
});
logly.options( { processors: processors } );
logly.log( 'some\nnewlines\nhere\nand\nthere');
// stdout: logly: some newlines here and there
```

### `options` object

You can pass in the above options all together:

```javascript
var processors = [];
processors.push( function( input ) {
    return input.replace(/\n/g, ' ');
});
logly.options( { colour : true, date : 'iso' , processors: processors } );
```

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