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

cgil-log

v3.0.1

Published

Goeland client side log class (now with TypeScript)

Downloads

8

Readme

cgil-log

Goeland client side colourful Log class (less then 3Kb and no dependencies)

  • version 3 was rewritten in TypeScript and bundled with Rollup.Js *

since version >2.0.1 you get the name of caller function for free

Getting Started

Install cgil-log in your favorite shell :

npm i -P cgil-log

Then to import the class library just use this line in your code

import { Log } from 'cgil-log'
const log = new Log('myModule', logLevel)

Based on the value of the enum logLevel [0-4] your messages will appear or not.

0 : none --> no log will be done, typically for a build in production

  1. : error --> only errors will appear log.e('my error msg)
  2. : warning --> only errors and warnings will appear
  3. : trace
  4. : info --> all logs type will appear

Just in case you wonder the levelLog enum is exported and is also available in the type definition file : cgLog.d.ts

export enum levelLog {
    none,   // = 0
    err,    // = 1
    warn,   // = 2
    trace,  // = 3
    info,   // = 4
}

How to use in the browser

Inside the browser you need to include the minified umd version (2.6Ko only). The library is exposed via the cgLog 'namespace'.

You can have a look in the examples directory.

Basically it's just a classical script :

<script src="../dist/cgLog.umd.js"></script>

Then in your javascript code

const log = new cgLog.Log('myModule', cgLog.levelLog.info)
const log = new cgLog('myModule', 4)
function myNiceFunction(v) {
  log.t('Entering in my function with parameter v:', v)
  log.l('my log message inside my function ', v)
  log.w('my warning message in my function', v)
  log.e('my error message in my function', v)
}

  let myVar = 'a nice string content'
  let myObj = { key: 1, msg: 'hello world !' }
  
  log.l('my log message outside any function', myVar)
  log.w('my warning message outside any function', myObj)
  log.e('my error message outside any function', myObj)
  log.t('my trace message outside any function');
  
  myNiceFunction(myVar)

will give you at the console (with different colors):

alt text