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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kkg/logger

v2.3.0

Published

Logger Wrapper using Winston for Node.js

Downloads

52

Readme

Logger

A Powerful Logger module Made by @rentspree

Features

  • Winston Logging
  • Google Stackdriver Logging
  • Elasticsearch Logging

Install

npm install --save @rentspree/logger

# Winston Logging Usage

import createLogger from "@rentspree/logger"

const logger = createLogger({ logLevel: "info" })

logger.info("hello info")

logger.info("hello %s", "hola")

logger.info("hello %s %s", "hola", "people")

const obj = { _id: "21344325", name: "John Doe" }

logger.info(obj)

logger.error("user Object", obj)

logger.debug("should not log this message")

Log Levels Options

  • default
  • silly
  • verbose
  • debug
  • info
  • warn
  • error

Log Format Options

  • text - default
  • json

Logging with JSON Format

import createLogger from "@rentspree/logger"

const logger = createLogger({ logLevel: "info", logFormat: "json" })

const obj = { _id: "21344325", name: "John Doe" }

logger.info(obj)

logger.error("user Object", obj)

Production Environment

Production will output with JSON format by default for support stackdriver

NODE_ENV=production

# Google Stackdriver Logging Usage

Alternative logging for store log from our application to Stackdriver logging

import createStackdriverLogger from "@rentspree/logger/dist/stackdriver"
// or
import { createStackdriverLogger } from "@rentspree/logger"

const credentials = JSON.parse(
  fs.readFileSync(path.join(__dirname, "../private-key/logging-key.json")),
)

const logger = createStackdriverLogger({ credentials, logName = "example" })
logger.error("error level")
logger.warn("warning level")
logger.warning("warning level")
logger.info("info level")
logger.debug("debug level")
logger.notice("notice level")
logger.critical("critical level")
logger.alert("alert level")
logger.emergency("emergency level")

// ** Support only string and object and only one param **
logger.info("text log message")
logger.info({ _id: "21344325", name: "John Doe" })

Log Levels Options

  • error
  • warning
  • info
  • debug
  • notice
  • critical
  • alert
  • emergency

Log Format Options

  • json - support only json

# Elasticsearch Logging Usage

Alternative logging for store log from our application to ELK Stack. Powered by https://github.com/vanthome/winston-elasticsearch

Elasticsearch Mapping

Please ensure that in Elasticsearch has *app_logs-* mapping pattern to be ensured as parsed JSON. if not you can copy from mapping/message.json folder

Available Options

These are default options you can override value by passing an option when initialize createElasticsearchLogger instance

{
  logLevel: "info",
  esHost: "http://localhost:9200",
  esVersion: 7,
  esEnvPrefix: "dev",
  esIndexPrefix: "app_logs",
  esIndexSuffixPattern: "YYYY-MM",
  esRequestTimeout: 10000,
  esMaxRetries: 1,
}

Example

import createElasticsearchLogger from "@rentspree/logger/dist/elasticsearch"
// or
import { createElasticsearchLogger } from "@rentspree/logger"

const logger = createElasticsearchLogger({
  logLevel: "info",
})

logger.info("test", {})

logger.info({firstName:'John',lastName:'snow'})

logger.info("info message")

const obj = { _id: "21344325", name: "John Doe" }

logger.error("user object message", obj)

logger.debug("should not log this message")

// circular structure
const o = { b: 1, a: 0 }
o.o = o
logger.info("test circular structure", o)

// the global logger name can be set via `setName`
logger.setName("rentspree-auth-service-v2")

// can create a new logger bind to the metadata via createMeta
const controllerLogger = logger.createMeta("controller.js")
controllerLogger.info("this is log with metadata to controller")

const externalServiceLogger = logger.createMeta("external-service.js")
externalServiceLogger.info("this is log with metadata to external-service")

Log Levels Options

  • silly
  • verbose
  • debug
  • info
  • warn
  • error

License

MIT © RentSpree