# log-my-ass

> simple nodejs logger

Latest version **1.0.2** (published 2021-11-11) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install log-my-ass
pnpm add log-my-ass
yarn add log-my-ass
bun add log-my-ass
```

## 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 | 1.0.2 |
| Published | 2021-11-11 |
| First published | 2021-11-11 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | whitekeep |
| Maintainers | whitekeep |
| Keywords | logger, nodejs, expressjs |

## Links

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

## 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.2 (latest) — 2021-11-11
- 1.0.1 — 2021-11-11
- 1.0.0 — 2021-11-11

## README

# log-my-ass

simple nodejs logger

# Get start

```
npm install log-my-ass
```

## Init

```js
const Logger = require('log-my-ass');
const log = new Logger(
  {
    info: {
      console_output: true,
      file_write: true,
      file_path: './path/to/info.log',
    },
    error: {
      console_output: true,
      file_write: true,
      file_path: './path/to/error.log',
    },
    access: {
      console_output: true,
      file_write: true,
      file_path: './path/to/acceess.log',
    },
  },
  'Start'
);

// OR:

// firstly add configuration:
config = {
  info: {
    console_output: true,
    file_write: true,
    file_path: './path/to/info.log',
  },
  error: {
    console_output: true,
    file_write: true,
    file_path: './path/to/error.log',
  },
  access: {
    console_output: true,
    file_write: true,
    file_path: './path/to/acceess.log',
  },
};

// and init
const Logger = require('log-my-ass');
const log = new Logger(config, 'Start');
```

## Usage

```js
// log classified as a "info" log
log.info('Hello world!');

try {
  some.code.with.error();
} catch (err) {
  log.error(err);
  // err it's error string or object
}
// log classified as a "error" log

log.error(err, "it's error message");
// log classified as a "error" and "info" log

// => it's equivalent
log.error(err);
log.info("it's error message");
```

## Log expressjs req and res

Add this in your main `index.js` file

It log classified as a "access" log

```js
app.use((req, res, next) => {
  log.access(req, res);
  next();
});
```

# Log message syntax

Example of output:

```
[04-11-2021 21:20:12] [Start] Message
```

- First scopes `[04-11-2021 21:20:12]` it's date and time in `es-CL` locales
- `[Start]` it's prefix. Declared in logger init
- `Message` it's log text, string or obj of error without `\n` symbols

# Configuration

```json
{
  "info": {
    "console_output": true,
    "file_write": true,
    "file_path": "./path/to/info.log"
  },
  "error": {
    "console_output": true,
    "file_write": true,
    "file_path": "./path/to/error.log"
  },
  "access": {
    "console_output": true,
    "file_write": true,
    "file_path": "./path/to/acceess.log"
  }
}
```

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