1.0.1 • Published 5 years ago

s3pweb-logger v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

This is a simple lib to log message

Installation

npm install s3pweb-logger

Config

Configurations are stored in configuration files within your application, and can be overridden and extended by environment variables, command line parameters, or external sources. See : http://lorenwest.github.io/node-config/

  1. Create a config folder

  2. Create a file(s) with the name of your environment(s) like test.json

  3. Paste this configuration template :

{
   "name": "your-application-name",

    "logger": {
    "source": false,
    "console": {
      "enable": true,
      "level": "debug"
    },
    "file": {
      "enable": true,
      "level": "info",
      "dir": "./logs"
    },
    "server": {
      "enable": true,
      "level": "trace",
      "url": "0.0.0.0",
      "port": "9998",
      "type": "elk"
    },
    "ringBuffer": {
      "enable": true,
      "size": 50
    }
  }
}
  1. Adapt values with your expectations

Example :

const log = require('s3pweb-logger').logger
const { logger } = require('s3pweb-logger')

const child = log.child({ child: 'childName' })

log.info('one message from log')
logger.info('one message from logger')
child.info('one message from child')

Run example :

Pass the name of your environnement with NODE_ENV=xxxx before node

NODE_ENV=test node example/example.js

Bonus :

To start a ELK stack on docker :

chmod +x example/startElk.sh 

./example/startElk.sh

Or with docker compose :

docker-compose -f example/docker-stack.yaml up -d

Open your favorite browser : http://localhost:5601

Create an index with just (replace logstash- by *)

1.0.1

5 years ago

1.0.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago