# logmore

> Simple logger for node.js

Latest version **2.1.0** (published 2014-09-13) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.1.0 |
| Published | 2014-09-13 |
| First published | 2014-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | Etienne TISSIERES |
| Maintainers | etissieres |
| Keywords | log, logger |

## Links

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

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^2.4.1

## 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) — 2014-09-13
- 2.0.0 — 2014-08-31
- 1.1.0 — 2014-08-30
- 1.0.0 — 2014-07-13

## README

[ ![Codeship Status for etissieres/logmore](https://www.codeship.io/projects/0c8ef6d0-1258-0132-e040-422f63fdd837/status)](https://www.codeship.io/projects/33208)

# logmore

Logger for node.js

## Installation

    $ npm install logmore
    
## Usage

logmore let you create a logger by invoking the exported function.
You can enable / disable a logger for a specified namespace.

Loggers are disable by default.

```js
var http = require('http');
var logmore = require('logmore');
logmore.use(require('logmore-console')());

var logger = logmore('http');
logmore.enable('http', 'info');

http.createServer(function (req, res) {
  logger.debug(req.method + ' ' + req.url);  // this log will not be processed : min level is 'info'
  res.end('Hello world !\n');
}).listen(1337, '127.0.0.1');
logger.info('Server running at http://127.0.0.1:1337');
```

Note : you can enable / disable a set of loggers with a single instruction :

```js
logmore.enable(['sample:namespace', 'foo:bar'], 'info');
logmore.disable(['sample:namespace', 'foo:bar']);
```

## Hierarchy

Namespaces are hierarchical. The separator is `:`.

 - Enabling the namespace `test:*` will enable each namespace in the hierarchy, such as `test:sample`.
 - Enabling the namespace `test*` will enable the namespace `test` and each namespace in the hierarchy, such as `test:sample`. 

Enabled namespaces or namespaces hierarchy are stored so that if you create a new logger with an enabled namespace, it will be enabled.

## Processors

logmore is a core. You can make it use processors to handle logs.
To do this, call the use function.
For example, this code will log

 - to the console thanks to the 'logmore-console' module
 - to a file thanks to the provided processor

```js
var fs = require('fs');
var logmore = require('logmore');
logmore.use(require('logmore-console')());

logmore.use(function (namespace, level, messages) {
  var log = '[' + namespace + '][' + level + ']';
  messages.forEach(function (message) {
    log += ' ' + message + '\n';
  });
  fs.appendFile('app.log', log);
});

logmore.enable('test:sample', 'trace');
var logger = logmore('test:sample');
logger.debug('simple log', {hello: 'world'});
```

You may also register processors for a specific logger. To do this : 

```js
var logmore = require('logmore');

logmore.enable('test:sample', 'trace');
var logger = logmore('test:sample');

logger.use(function (namespace, level, messages) {
  if (level === 'error') {
    console.log('Specific processor for the error level of ' + namespace);
  }
});

logger.error('simple log', {hello: 'world'});
```

## License

[MIT](license)

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