# @gauntface/logger

> A simple console abstraction with some little extras

Latest version **3.0.115** (published 2023-04-23) · 0 weekly downloads

## Install

```sh
npm install @gauntface/logger
pnpm add @gauntface/logger
yarn add @gauntface/logger
bun add @gauntface/logger
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.115 |
| Published | 2023-04-23 |
| First published | 2022-07-05 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 26.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | gauntface |
| Keywords | console, log, logger |

## Links

- npm: https://www.npmjs.com/package/@gauntface/logger
- npm.io page: https://npm.io/package/@gauntface/logger

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

- 3.0.115 (latest) — 2023-04-23
- 3.0.114 — 2023-04-22
- 3.0.113 — 2023-04-21
- 3.0.112 — 2023-04-18
- 3.0.111 — 2023-04-17
- 3.0.110 — 2023-04-14
- 3.0.109 — 2023-04-11
- 3.0.108 — 2023-04-07
- 3.0.107 — 2023-04-04
- 3.0.106 — 2023-04-02
- 3.0.105 — 2023-03-30
- 3.0.104 — 2023-03-26
- 3.0.103 — 2023-03-26
- 3.0.102 — 2023-03-21
- 3.0.101 — 2023-03-18
- … 100 more at https://npm.io/package/@gauntface/logger/versions

## README

![Image of the default emoji used by the logger](default-social.png)

# @gauntface/logger

`@gauntface/logger` is a simple library aimed at making it easy to add
colored and prefixed logs to a project in both Node and the browser.

![Screenshot of logger demos in Node and Browser](logger-screenshots.png)

## Usage in Browser

```html
<script src="https://unpkg.com/@gauntface/logger@3.0.2/build/browser-globals.js"></script>
<script>
  console.log('\n\nThe following are the logs out of the box:\n\n\n');

  // Use the default logger
  gauntface.logger.debug(`console.debug()`);
  gauntface.logger.info(`console.info()`);
  gauntface.logger.log(`console.log()`);
  gauntface.logger.warn(`console.warn()`);
  gauntface.logger.error(`console.error()`);

  console.log('\n\nYou can customize the prefix to something you\'ll recognize:\n\n\n');

  // Customize the default loggers prefix
  gauntface.logger.setPrefix(`Logger Demo`);
  gauntface.logger.log('👋');

  // Create your own logger instances
  console.log('\n\nYou can create different instances of "Loggers":\n\n\n');

  const simpleLogger = new gauntface.Logger({
    prefix: 'My App/Demo',
  });
  simpleLogger.log(`Example message`, {
    message: 'Works just like console.log()'
  });

  console.log('\n\nYou can also customize each log level prefix:\n\n\n')

  // Use your own prefix for some or all of the log
  // levels
  const complexLogger = new gauntface.Logger({
    prefix: {
      [gauntface.LogLevels.GROUP]: 'My App/Groups',
      [gauntface.LogLevels.ERROR]: '👻',
    },
  });
  complexLogger.log('The logger lib supports groups');
  complexLogger.group(`Like this one`);
  complexLogger.log(`I'm nested`);
  complexLogger.groupCollapsed(`You can collapse them too`);
  complexLogger.error(`Boo`);
  complexLogger.groupEnd();
  complexLogger.groupEnd();
</script>
```

## Usage in Node

Using the default logger:
```javascript
const {logger} = require('@gauntface/logger');

logger.debug(`console.debug()`);
logger.info(`console.info()`);
logger.log(`console.log()`);
logger.warn(`console.warn()`);
logger.error(`console.error()`);

// Customize the default loggers prefix
logger.setPrefix(`Logger Demo`);
logger.log('👋');
```

Using a custom logger
```javascript
const {Logger} = require('@gauntface/logger');

const simpleLogger = new Logger({
  prefix: 'My App/Demo',
});
simpleLogger.log(`Example message`, {
  message: 'Works just like console.log()'
});
```

The package.json defines a main and a browser property which
should allow you to use `@gauntface/logger` for importing, if
however you want to explicitly get the browser / node version
please use the following imports:

- For the browser:
    ```javascript
    import {logger, Logger, ...} from '@gauntface/logger/src/browser/browser.js';
    ```
- For node:
    ```javascript
    import {logger, Logger, ...} from '@gauntface/logger/src/node/node.js';
    ```

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