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

@tgsnake/log

v1.6.3

Published

logging framework for tgsnake

Downloads

331

Readme

Tgsnake Log

This framework is used to better display logs on your console or terminal.

Available log levels

This framework using env in node and localStorage in browser for betters performance :

  • LOGLEVEL : To save the log level. So only declaring in one instance, all instance can read that log level.

  • LOGFILTERS : To save any instance that can display context on console or terminal (according to the name that was given at the time of initialization). default is all,unamed.

  • LOGWARNINGLEVEL : To save the warning level.

  • debug or verbose : To showing all level in terminal.

  • info : Shows only context with level info on console or terminal.

  • error : Shows only context with level error on console or terminal.

  • warn : Shows only context with level warn (warning) on console or terminal.

  • none : Will not display anything on console or terminal

How to use

const { Logger } = require('@tgsnake/log');
const log = new Logger({
  name: 'some-string-without-space-here',
  level: ['debug'], // default level for this log
});

log.log('Hello World'); // (name) info - Hello World DD/MM/YY hh:mm:ss.ms

Class Method

  • log : Print log without template.
  • info : Print log as info level.
  • error : Print log as error level.
  • warning : Print log as warning level.
  • combine : Print log as multiple level.
  • debug : Print log as debug level.
  • setLogLevel : Setting the log level.
  • setWarningLevel : Setting the warning level. hard if you want show the context in all log level, soft if you want show the context only in warning or debug or verbose level.
  • setFilters : Setting any instance that can display context in the console or terminal.

Options

| parameter | type | description | | :-- | :-: | :-- | | name | string | Name of logger instance, default is unamed | | level | Array of debug, none, info, error, verbose | The level of the logger. By default it will take the value from the env LOGLEVEL or if it is not available it will automatically go into debug level | | customColor | Color | Console color customization |

Color

On deno supports chalk v5 customization while on node supports chalk v4 customization. For RGB, HSL (only for node), HSV (only for node), HWB (only for node), you can use the format: format(a,b,c) example rgb(0,0,0) or hsl(0,0,0). And you can directly provide the hex code (eg: #fff). In nodes, you can also use keywords from CSS like orange.

| category | type | description | | :------- | :----: | :--------------------------------------- | | name | string | color of logger name | | date | string | color of date | | debug | string | color when debug level and verbose level | | info | string | color when info level | | error | string | color when error level | | warning | string | color when warning level |

Example

const { Logger } = require("@tgsnake/log")
const log = new Logger({
  name : "some-string-without-space-here",
  level : ["debug"] // default level for this log,
  customColor : {
    debug: 'blue',
    info: 'rgb(0,255,0)',
    error: '#ff0505',
    warning: 'hsv(44,98,100)',
    name: 'azure',
    date: 'grey',
  }
})

MIT LICENSE

Build with ♥️ by tgsnake dev.