npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-bridge-sdk

v0.0.16

Published

Improvising NodeJS's features

Downloads

3

Readme

node-bridge-sdk

Bunch of light weight functional components for your node application. No extra package, goal is to build something beautiful straight from what nodejs provides.

Getting Started

npm i node-bridge-sdk

or

yarn add node-bridge-sdk

Logger/Console npm version

Fully configurable logger module, that automatically captures all logs inside two separate files. Along with traditional functionality of console, it appends the timestamp and name of the logger as well, so you know what happened and when it happened and you don't have to deep dive into unnecessary noise of server logs, while debugging.

Extremely light package, with no external "dev" dependencies. Everything happens via traditional functions/packages exposed by NodeJS

Installation

npm  install node-bridge-sdk
or
yarn  add node-bridge-sdk

Usage

import { getLogger } from  'node-bridge-sdk';

const  logger = getLogger({name:  'users:getData'});
// or const logger = getLogger();
logger.debug('got users data');

// emits
[debug](users:getData):[2021-10-16T03:04:01.976Z] : got users data
on console and stdout.log file

Functions

logger.log(123, "hello:", `${userId}`);
logger.error(...)
logger.debug(...)
logger.info(...)
logger.warn(...)
logger.trace(...)
logger.table(...)

Options

Other ways to initialize Logger

name(recommended use)

const  logger = getLogger({name:  'users:setData'});
logger.debug('set user data');

// emits
[debug](users:setData):[2021-10-16T01:49:37.304Z] : set user data

Name is used while emitting messages. for eg: (users:setData) in the message above

logInFile

const  logger = getLogger({name:  'users:setData'});
logger.debug('set user data');

Decides whether to log a message type into stdout.log and stderr.log file or not. By default all messages are added to the files

Default logInFile values
logInFile = {
	log:  true,
	warn:  true,
	error:  true,
	debug:  true,
	info:  true,
	trace:  true,
	table:  true,
}

const  logger = getLogger({name:  "users:setData", logInFile: {debug:  false, error: false}});
logger.debug('I will not be added to file');
logger.log('I will be added to the file, because of default config');
logger.error(new Error('custom error, I wont be added to stderr.log, because you choose not to'));

displayToConsole

const  logger = getLogger({name:  "users:setData", displayToConsole: {debug:  false, error: true}});

By default all messages are logged into console, you can turn on/off that feature via displayToConsole option value

logWithTrace

const  logger = getLogger({name:  "users:setData", logWithTrace: {debug:  false, error: true}});

By default no messages are logged with trace information, you can turn on/off that feature via logWithTrace option value

appendTimeStamp

const  logger = getLogger({name:  "users:setData", appendTimeStamp: {debug:  false, error: true}});

By default all messages have timestamp appended to the messages, which are logged in console or in file. However, you are free to adjust showing timestamp per function. Example of timestamp: [debug](users:setData):[2021-10-16T01:49:37.304Z] : set user data

outputFileName

By default output from log, info, trace, table and debug is stored in stdout.log and output from error and warn is stored in stderr.log. However, you can pass in outputFileName, with the file name that you want.

const  logger = getLogger({name:  "users:setData", outputFileName: './my-logger-output.log'});

errorOutputFileName

You can also change the file name where error and warn messages are stored

const  logger = getLogger({name:  "users:setData", outputFileName: './my-logger-error.log'});

Additional features

  • If both displayToConsole and logInFile is false for a function is false, the Logger is smart enough to log the function into the console.