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

caramel-puppy

v1.0.4

Published

Intelligent log manager.

Downloads

11

Readme

CaramelPuppy 🐕🐶

npm npm GitHub Build Status

CaramelPuppy is an intelligent log manager, it allows to save the logs in a caramelPuppy.json file in the project root. Integration with express and credential protected web interface for log viewing.

Content Guide

Configuration

First install the caramelPuppy package

  • Via Node Package Manager (NPM):
npm install caramel-puppy
  • Via yarn:
yarn add caramel-puppy

Then import caramelPuppy into your project:

const caramelPuppy = require("caramel-puppy")({
    __filename
})

The code above is enough for caramelPuppy to work. The __filename parameter is Node's own variable, which tells which file that code is being run.

Use

After the setup is a success. The caramelPuppy will return some functions.

caramelPuppy.log()

Similar to the console.log() function it takes a number of parameters. And save it to the caramelPuppy.json log array like this:

{
    date:"2019-12-11 10:12:12",
    type:"log",
    filename:"index.js",
    log:["Hello","World"] //array of arguments
}

And will display on the console:

LOG Hello World

caramelPuppy.appStart()

Useful to know when your app started. In caramelPuppy.json:

{
    filename:"index.js",
    type:"appStart",
    date:"2019-12-11 10:12:12"
}

And will not display anything on the console.

Express

CaramelPuppy uses express middleware to intercept requests and save the http method, status code, and URL. By default the information will only be saved at the end of the request.

Not required to use Express.

Configuration

const express = require("express")
const app = express()
const caramelPuppy = require("caramel-puppy")({
    __filename,
    express:app
})

Messages will be displayed on the console:

Express Start GET /hi

Express End GET /hi 200

Start means the request has been received. End means the request has been terminated.

In the future with the implementation of trace it will be easier to monitor the logs that happened in a request.

Web interface connection

CaramelPuppy provides a web interface to view logs simply and securely. Setting this interface requires setting an environment variable, so you can create the .env file in the root:

CARAMELPUPPY_KEY=exemple

When creating this file, caramelPuppy uses dotenv to read it. So just go to url: http://mydomin.com/caramelPuppy?credential=example

Request

caramelPuppy.request(req) receives the request req and error as a parameter:

request("google.com",{
	time:true //Passing time: true will save elapsedTime
},(err,req,body)=>{
	caramelPuppy.request(req,err)
})

And will display on the console:

Request GET 200 google.com

ChangeLog

  • 1.0.0: Initial release
  • 1.0.1: Fixed error looking for href from url in request

Contributors

My sincere and thank you to all who contributed.

Contributions

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests to us.

License

This project is licensed under the MIT license - see the LICENSE file for details.