# leo-logger

> NodeJS Logger by LeoInsights. Logging the way it should be!

Latest version **1.0.7** (published 2025-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install leo-logger
pnpm add leo-logger
yarn add leo-logger
bun add leo-logger
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2025-01-23 |
| First published | 2018-06-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | LeoInsights |
| Maintainers | leoinsights, jgrantr, czirker, elsmob, francislewis |
| Keywords | logger, logging, logs, sysadmin, bunyan, pino, loglevel, console, winston, loggly, debugger |

## Links

- npm: https://www.npmjs.com/package/leo-logger
- Repository: https://github.com/LeoPlatform/leo-logger
- Homepage: https://github.com/LeoPlatform/leo-logger#readme
- Issues: https://github.com/LeoPlatform/leo-logger/issues
- npm.io page: https://npm.io/package/leo-logger

## Dependencies (1)

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

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

- 1.0.7 (latest) — 2025-01-23
- 1.0.3 (beta) — 2023-07-31
- 1.0.6 — 2024-11-22
- 1.0.5 — 2024-11-21
- 1.0.4 — 2024-10-24
- 1.0.2 — 2023-07-31
- 1.0.1 — 2018-09-19
- 1.0.0 — 2018-06-28

## README

# Leo-Logger
Such an awesome logger that we had to break it out from the LEO SDK and make it its own project!

## Available methods
 * sub
 * info
 * json
 * time
 * timeEnd
 * log
 * debug
 * error
 * warn
 * trace
 * configure

## Available configuration options
 * a = all
 * t = time
 * i = info
 * d = debug
 * e = error
 * w = warn
 * x = trace
 * j = json
 * T = printTimestamp

## Usage example:
```bash
export LEO_LOGGER='/.*/d'
```

```bash
export LEO_LOGGER='/my-logger/wei;/.*/ei'
```


## Working with namespaces
You can log logs for specific namespaces by passing a string when requiring the leo-logger. Example:
```javascript
const logger = require('leo-logger')('my-special-namespace');
```
When you use a namespace, logging works the same, but the output will be prefixed with the namespace:
```javascript
logger.log('My namespaced log');
// outputs: my-special-namespace my namespaced log
```

If you want to display logs for certain namespaces only, you can adjust LEO_LOGGER to match the namespace.
```bash
# Example outputting all logs for my-special-namespace
export LEO_LOGGER='/my\-special\-namespace/a'
```

You may notice in the previous example how it appears we’re using regex. This allows you to employ more powerful namespace logging.
As an example, let’s say you have a shopping cart, and you want to have logs specific to the checkout process.
Each of the checkout pages would include the leo-logger. I'm going to use an example of 2 checkout pages, which would look like this:
```javascript
const logger = require('leo-logger')('checkout-payment');
```
```javascript
const logger = require('leo-logger')('checkout-process-order');
```

Then if you want to display logs for the process-order page, you would do this:
```bash
export LEO_LOGGER='/checkout\-process\-order/a'
```
But if you want to display logs for all checkout pages, you can use the power of regex to select everything starting with “checkout”:
```bash
export LEO_LOGGER='/checkout.*/a'
```

### Loggers
```javascript
logger.log('my logged message');
logger.info('my info');
logger.debug('just some debugging code');

```

### Timers
```javascript
// start a timer
logger.time('myTimer');
// stop a timer
logger.timeEnd('endTimer');
```

## To-Do
More documentation with examples with code and output.

# Support
Want to hire an expert, or need technical support? Reach out to the Leo team: https://leoinsights.com/contact

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