1.9.2 • Published 8 months ago

log-2-route v1.9.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

About The Project

I was looking for an easy-to-use file logger for my Next.js apps, suitable for both development and production, without the need to deploy to Vercel. I tried several popular solutions, but none of them worked well for my use cases, so of course I had to roll my own.

Getting Started

Prerequisites

Installation

Install

npm i log-2-route

Configure

node ./node_modules/log-2-route/install/config

The config script will perform a few tasks

Configuration

{
    "logFile": {
      "format": "ndjson",
      "enabled": true,
      "fileName": "app.log",
      "location": "./",
      "timeType": "epoch",
      "colorizeStyledLog": false
    },
    "console": {
      "format": "styled",
      "enabled": true
      "timeType": "epoch",
      "colorizeStyledLog": true
    }
  }

Logfile Options

Console Options

Usage

Importing

import { logger } from 'log-2-route';

Logging

logger.info('messsage');
logger.error('message');
logger.success('message');
logger.debug('message');
logger.warn('message');

Example

try {
  // codes...
}
catch(e) {
  logger.error((e instanceOf Error).message);
  logger.debug((e instanceOf Error).stack);
}

*logger.debug() will only output to the logfile.

logger.success('User has done a thing!');

Logger can take multiple arguments and argument types

logger.info('User logged in', { level: 1 }, 12345);

And if set to styled will log

[7378237287] INFO - User logged in level: 1

Output

[12/23/2024, 7:40:59 AM] INFO - User Rudy Schneider logged in
{"type":"info","time":{"epoch":1734957920354},"data":{"message":"User Rudy Schneider logged in"}}

License

Distributed under the MIT. See LICENSE.txt for more information.

Contact

Nathan Schneider - nlschneider@gmail.com

GitHub: [https://github.com/nathanlschneider/log-2-route] NPM: [https://www.npmjs.com/package/log-2-route]

1.9.2

8 months ago

1.8.14

11 months ago

1.8.13

11 months ago

1.8.12

11 months ago

1.8.11

11 months ago

1.8.10

11 months ago

1.8.9

11 months ago

1.8.8

11 months ago

1.8.7

11 months ago

1.8.6

11 months ago

1.8.5

11 months ago

1.8.4

11 months ago

1.8.3

11 months ago

1.8.2

11 months ago

1.8.0

11 months ago

1.7.12

11 months ago

1.7.11

11 months ago

1.7.10

11 months ago

1.7.9

11 months ago

1.7.8

11 months ago

1.7.7

11 months ago

1.7.6

11 months ago

1.7.5

11 months ago

1.7.3

11 months ago

1.7.2

11 months ago

1.7.1

11 months ago

1.7.0

11 months ago

1.6.2

11 months ago

1.6.1

11 months ago

1.6.0

11 months ago

1.5.1

11 months ago

1.5.0

11 months ago

1.3.1

11 months ago

1.3.0

11 months ago