# xxd-log

> Simple console logger with colors and levels.

Latest version **2.0.0** (published 2020-11-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install xxd-log
pnpm add xxd-log
yarn add xxd-log
bun add xxd-log
```

## 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.0.0 |
| Published | 2020-11-05 |
| First published | 2017-09-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | linkeo |
| Maintainers | linkeo |
| Keywords | logger, colorful, console |

## Links

- npm: https://www.npmjs.com/package/xxd-log
- Repository: https://github.com/linkeo/xxd-log
- Homepage: https://github.com/linkeo/xxd-log#readme
- Issues: https://github.com/linkeo/xxd-log/issues
- npm.io page: https://npm.io/package/xxd-log

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [moment](https://npm.io/package/moment.md) ^2.29.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.0.0 (latest) — 2020-11-05
- 1.0.4 — 2020-02-07
- 1.0.3 — 2018-07-31
- 1.0.2 — 2017-10-17
- 1.0.1 — 2017-10-17
- 1.0.0 — 2017-09-07

## README

## Usage

```js
const log = require("xxd-log");

// Different log levels
// Accept same arguments as `console.log()`
const count = 5;
log.trace("count: %d", count);
log.debug("count:", count);
log.info(`count: ${count}`);
log.warn({ count });
log.error(new Error(`count (${count}) is wrong.`));
log.fatal("Duang!");

// Use chalk directly
console.log(log.chalk.red("This is red."));
```

## Configure

```js
// Change options of the default logger instance.

log.withLabel = false; // Do not display labels before messages.
log.withTimestamp = false; // Do not display current time before messages.
log.highlightStackTrace = false; // Do not highlight key positions in error stack trace.
log.timestampFormat = "HH:mm:ss.SSS"; // Customize the time format.

log.withLabel = log.defaultOptions.withLabel; // reset an option to default value.
```

```js
// Use an individual instance with different options

const anotherLogger = log.newLogger({
  withLabel: false,
  withTimestamp: false,
  highlightStackTrace: false,
});
```

You can change these options at any time in the process, and will take effect from next call of logging.

For further instruction of time format, please see [moment.js documentation](http://momentjs.com/docs/#/displaying/format/)

### Options List

| Option              | Type    | Description                                                                                                                              |
| ------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| withTimestamp       | boolean | Control if print message with timestamp before, default to `true`                                                                        |
| withLabel           | boolean | Control if print message with label (indicating log level) before, default to `true`                                                     |
| timestampFormat     | string  | Define how timestamp looks like, see `moment.format()` (http://momentjs.com/docs/#/displaying/format/), default to 'YYYY-MM-SS HH:mm:ss' |
| highlightStackTrace | string  | Control if highlight files in project (in `process.cwd()`, and not in `node_modules`) in error stack trace. default to `true`            |

## Requirements

### v2.x

- **Node.js** > `12.4.0`

### v1.x

- **Node.js** > `6.0.0`
- or **Node.js** > `4.0.0` with `--harmony`

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