Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ecs-logs-js

Package Overview
Dependencies
Maintainers
300
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ecs-logs-js

Simple Node.js console logger that outputs human friendly and ecs-logs compatible messages

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-43.63%
Maintainers
300
Weekly downloads
 
Created
Source

ecs-logs-js

Note

While this project remains available under its open source license for anyone to use, we are not actively maintaining it, so issues and pull requests may be ignored.

A simple Node.js console logger that outputs human friendly messages in development and ecs-logs compatible messages in production. Supports all of Node's primitive data types, including those that can't be JSON stringified like Error, Map, Set and BigInt.

TypeScript types are also included in the package.

Development log output example

Install

yarn add ecs-logs-js
# or
npm install ecs-logs-js

Usage

import { Logger } from 'ecs-logs-js'

const logger = new Logger({ devMode: true })
logger.info('Server started at http://localhost:8000')
logger.warn('Request rate limited', { ip: '127.0.0.1' })
logger.error('🚨 Unexpected Error', new Error('Failed to connect to Postgress'))

API

new Logger(options?)

Creates a new logger instance.

options

Type: object

level

Type: 'emerg' | 'alert' | 'crit' | 'error' | 'warn' | 'notice' | 'info' | 'debug'
Default: 'debug'

Sets the maximum log level that will be output. By setting this option to 'info', it can be used to disable debug logs in production.

devMode

Type: boolean
Default: process.env.NODE_ENV === 'development'

Enables the human friendly development output.

logger.log(level, message, data?)

Logs a message at the given log level.

level

Type: 'emerg' | 'alert' | 'crit' | 'error' | 'warn' | 'notice' | 'info' | 'debug'

Log level for the message.

message

Type: string

The message to log.

data

Type: any

Any additional data to log with the message. This can be any type.

logger.emerg(message, data?)

logger.alert(message, data?)

logger.crit(message, data?)

logger.error(message, data?)

logger.warn(message, data?)

logger.notice(message, data?)

logger.info(message, data?)

logger.debug(message, data?)

Logs a message at the respective log level.

message

Type: string

The message to log.

data

Type: any

Any additional data to log with the message. This can be any type.

Development

Make sure you have Node >=10 and Yarn installed, and then run yarn install to install the development dependencies.

To run the tests use yarn test. To run the tests in watch mode use yarn test --watch.

To lint the files use yarn lint.

To compile the TypeScript files use yarn build.

Keywords

FAQs

Package last updated on 13 Dec 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc