# loglet

> A simple logger.

Latest version **0.2.0** (published 2016-02-18) · BSD-3-Clause license · 0 weekly downloads

## Install

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

## 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.2.0 |
| Published | 2016-02-18 |
| First published | 2014-10-23 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | YC |
| Maintainers | yc |
| Keywords | logger |

## Links

- npm: https://www.npmjs.com/package/loglet
- Repository: https://bitbucket.org/yinso/loglet
- npm.io page: https://npm.io/package/loglet

## Dependencies (1)

- [errorlet](https://npm.io/package/errorlet.md) ^0.2.0

## 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

- 0.2.0 (latest) — 2016-02-18
- 0.1.4 — 2015-04-20
- 0.1.3 — 2015-01-15
- 0.1.2 — 2014-10-31
- 0.1.1 — 2014-10-24
- 0.1.0 — 2014-10-23

## README

# Loglet - A Simple Logger.

`Loglet` is a simple configurable logger that can be configured to conditionally log a particular output. This is especially useful to be combined with command line parameter (or configuration files) to determine the output you are logging. 

The scenario loglet is designed for is for people who use `console.log` to trace through the program and has to frequently comment/uncomment them to see the different parts. By using `loglet` you can leave the programs to be and just enable/disable the comments by passing in settings, which are treated as regular expressions. 

## Install

    npm install loglet 


## Usage 

    var logger = require('loglet');
    
    logger.setKeys(['main', 'test']); // used to determine what to log. 
    
    logger.debug('main.first', 'hello world - this will be logged'); 
    
    logger.debug('test.first', 'this will also be logged');
    
    logger.debug('skip.me', 'this will not be logged');
    
    logger.error({error: 'stuff_happens', description: 'Errors will also be logged'});
    


## Desciption 

Do you use `console.log` to trace and debug the output of the program? If you do you'll find `console.log` is littered throughout the code, but you'll have to constantly go back and forth to comment/uncomment out the logging. `Loglet` is a replacement for those logging calls that allows you to leave those code alone but you can turn them on/off based on settings you pass in for the program. 

Let's say you use either `optimist` or `yarg` to parse the command line. You can then collect the debug arguments as follows: 

    var argv = require('yargs')
      .alias('d', 'debug')
      .argv;
    
    var logger = require('loglet');
    
    logger.setKeys(argv.d);
    
    logger.debug(...); // logger.debug is the main function that you'll use for conditional logging. 
    
    ...
    


To change what's being logged, just pass in different sets of keys through the command line. The keys are regular expressions, so you can have fine control over what's actually logged. 

    program -d main -d test\\.

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