🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@s3pweb/s3pweb-logger

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@s3pweb/s3pweb-logger

A simple lib to log message using bunyan to console, file and logstash.

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

npm (scoped)

This is a simple lib to log messages built on top of bunyan. This lib can send logs to the console, to a file or to a logstash instance.

Installation

npm install @s3pweb/s3pweb-logger

Configuration

The constructor expect a config object following this format:

{
  "name": "your-application-name",
  "logger": {
    "source": false,
    "console": {
      "enable": true,
      "level": "debug"
    },
    "file": {
      "enable": true,
      "level": "info",
      "dir": "./logs",
      "addHostnameToPath": true
    },
    "server": {
      "enable": true,
      "level": "trace",
      "url": "0.0.0.0",
      "port": "9998",
      "type": "elk"
    },
    "ringBuffer": {
      "enable": true,
      "size": 5
    }
  }
}

Example

const Logger = require('@s3pweb/s3pweb-logger')

const log = new Logger(config).get()
const child = log.child({ child: 'childName' })

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

Tests

Set the name of your environment 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 *)

FAQs

Package last updated on 17 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts