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

tinycalf-logger

v0.0.2-beta

Published

console logs, manage logs using mongodb, send you email when an error occurs

Downloads

3

Readme

Tinylogger overwrites console to provide a better output. At the same time, it insert your logs in mongodb for a easy management of logs. It also can keep you informed if an error happens in your project.

** This is a beta version and be careful when using it **

Your console would be like this :

normal console
[2018-04-17|17:33:25] INFO something happening
[2018-04-17|17:33:25] WARN you can do better here
[2018-04-17|17:33:25] ERROR something bad happened
[2018-04-17|17:33:25] ERROR something bad happened
Error: something bad happened
    at Object.<anonymous> (/home/tinycalf/Desktop/tinylogger/example.js:25:15)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
[2018-04-17|17:33:25] SUCCESS something has been done successfully

in your mongodb you will geth log like these:

{
    "_id" : ObjectId("5ad5b1546122fa70fa219ca1"),
    "location" : "    at Module._compile (module.js:643:30)",
    "type" : "ERROR",
    "msg" : "something bad happened\nError: something bad happened\n    at Object.<anonymous> (/home/tinycalf/Desktop/tinylogger/example.js:12:15)\n    at Module._compile (module.js:643:30)\n    at Object.Module._extensions..js (module.js:654:10)\n    at Module.load (module.js:556:32)\n    at tryModuleLoad (module.js:499:12)\n    at Function.Module._load (module.js:491:3)\n    at Function.Module.runMain (module.js:684:10)\n    at startup (bootstrap_node.js:187:16)\n    at bootstrap_node.js:608:3",
    "date" : ISODate("2018-04-17T08:33:24.068+0000"),
    "__v" : NumberInt(0)
}
{
    "_id" : ObjectId("5ad5b1546122fa70fa219ca2"),
    "location" : "    at Module._compile (module.js:643:30)",
    "type" : "SUCCESS",
    "msg" : "something has been done successfully",
    "date" : ISODate("2018-04-17T08:33:24.071+0000"),
    "__v" : NumberInt(0)
}
{
    "_id" : ObjectId("5ad5b19ccab981714a27b881"),
    "location" : "    at Module._compile (module.js:643:30)",
    "type" : "ERROR",
    "msg" : "something bad happened\nError: something bad happened\n    at Object.<anonymous> (/home/tinycalf/Desktop/tinylogger/example.js:12:15)\n    at Module._compile (module.js:643:30)\n    at Object.Module._extensions..js (module.js:654:10)\n    at Module.load (module.js:556:32)\n    at tryModuleLoad (module.js:499:12)\n    at Function.Module._load (module.js:491:3)\n    at Function.Module.runMain (module.js:684:10)\n    at startup (bootstrap_node.js:187:16)\n    at bootstrap_node.js:608:3",
    "date" : ISODate("2018-04-17T08:34:36.396+0000"),
    "__v" : NumberInt(0)
}

Install

npm install tinycalf-logger --save

if you use mongodb to log, you need to install it

sudo apt install mongodb

Usage

You can write a seperated file like this:

var logger = require("tinylogger")

logger.init({
  mongodb:"mongodb://localhost:27017/myproject",
  email:{
    smtp:{
      host: 'smtp.exmail.qq.com',
      port: 465,
      secure: true,
      auth: {
        user: '[email protected]',
        pass: 'password'
      }
    },
    from: "My project",
    receivers:["[email protected]"]
  },
})

in a whole project, you only need to init it once. But if you want test your file seperatedly, you need to require this file everywhere. If you don't need mongodb or email function, just don't write them in initial params:

logger.init({mongodb:"mongodb://localhost:27017/myproject"})

if you dont need both of mongodb and email, you don't even need to initial it. Then, you just need to console as normal like:

console.log("normal console")
console.info("something happening")
console.warn("you can do better here")
console.error("something bad happened")
console.error(new Error("something bad happened"))
console.success("something has been done successfully")

and you will get console like the above.