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

@cactus-technologies/logger

v2.2.3

Published

Customized Pino Logger for Cactus projects

Downloads

20

Readme

@cactus-technologies/logger

version npm

Customized Pino Logger for Cactus projects


Table of contents

Installation

npm install @cactus-technologies/logger

Usage

const logger = require('@cactus-technologies/logger')
const log = logger('demo')
log.info('hello world')
{
    "level": 30,
    "time": 0000000,
    "msg": "hello world",
    "pid": 5218,
    "hostname": "demo-host",
    "name": "demo",
    "v": 1
}
log.error('this is at error level')
{
    "level": 50,
    "time": 0000000,
    "msg": "this is at error level",
    "pid": 000,
    "hostname": "demo-host",
    "name": "demo",
    "v": 1
}

All arguments supplied after message are serialized and interpolated according to any supplied printf-style placeholders.

log.info('the answer is %d', 42)
{
    "level": 30,
    "time": 0000000,
    "msg": "the answer is 42",
    "pid": 000,
    "hostname": "demo-host",
    "name": "demo",
    "v": 1
}

An object can optionally be supplied as the first parameter. Each enumerable key and value of the mergingObject is copied in to the JSON log line.

log.info({ a: { b: 'c' } }, 'Attachment')
{
    "level": 30,
    "time": 0000000,
    "msg": "Nested Attachment",
    "pid": 000,
    "hostname": "demo-host",
    "name": "demo",
    "a": { "b": "c" },
    "v": 1
}

Errors get Serialized

log.error(new Error('an error'))
{"level":50,"time":0000000,"msg":"an error","pid":000,"hostname":"demo-host","name":"demo",
 "err":{"message":"an error","name":"Error",
"stack":"Error: an error
    at Object.<anonymous> (/Users/mechanicalhuman/Active/cactus/utils/packages/logger/example.js:12:11)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)"},"v":1}

The logger.child method allows for the creation of stateful loggers, where key-value pairs can be pinned to a logger causing them to be output on every log line.

const child = log.child({ extra: 'property' })
child.info('hello child!')
{
    "level": 30,
    "time": 0000000,
    "msg": "hello child!",
    "pid": 000,
    "hostname": "demo-host",
    "name": "demo",
    "extra": "property",
    "v": 1
}

API

Maintainers

Changelog

Find the CHANGELOG here, generated using Conventional Commits.

License

MIT © Cactus Technologies LLC