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

@lapita/loggy

v0.0.2

Published

[![MIT](https://img.shields.io/packagist/l/doctrine/orm.svg?style=flat-square)]() [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) [![All Contributors](https://

Downloads

4

Readme

MIT styled with prettier All Contributors flatstadt

Loggy, better than a simple console

Let's be honest. There are more wraps of the console than pieces of hay are in a haystack. Loggy offers a simpler way to use the console. It allows logging inside groups, which comes in handy to filter through your browser console when you mess up Angular detection change. Loggy also lets you log methods and properties by simply adding a decorator. And all this, while maintaining the file name and line.

Features

  • ✅ Log by group
  • ✅ Stylish log levels
  • ✅ Log methods
  • ✅ Log properties

Table of Contents

Installation

NPM

npm install @lapita/loggy --save

Yarn

yarn add @lapita/loggy

Usage

Start using Loggy couldn't be simplier. You need to create a file, preferably inside your src folder. Inside this file, you need to set the log level first, and then create an instance of Loggy by calling createLoggy.

This creation method requires a single object with contains the list of groups you want for your project. Some examples are login, authorization, and so on. These groups will make easier to filter your browser Console when you need to look for specific information associated to a component.

import { createLoggy, setLogLevel } from '@lapita/loggy';

import { environment } from './environments/environment';

// Set the log level
setLogLevel(environment.logLevel);

// Instance loggy
export const {debug, log, info, warn, error} = createLoggy(
  {
    global: 'global stuff', 
    auth: 'authorization', 
    dashboard: 'dashboard'
  }
);

Loggy wraps five log levels. From lower to higher level, you'll find debug, log, info, warn and error. There can be easily access by destructuring the return object. And you're ready to start using Loggy.

log.global('It preserves the line numbers', {obj: 'test'});
log.auth('auth failed');
log.dashboard('dashboard init');

Your IDE will suggest the available groups as soon as you type log..

Logging a property can be done by adding a @LoggyProperty. You need to pass in a function pointing to the log and group you want to use. This way, you'll be preserving the line and file where the property lays.

@LoggyProperty((t) => log.global(t), {logValue: true, accessType: 'set'})
title = 'Loggy! Open the console.';

This decorator admits the following options, which are self-explanatory.

{
  logCalls: boolean;
  logValue: boolean;
  accessType: 'get' | 'set' | 'get/set';
  enable: boolean;
}

Logging a method can be done by adding a @LoggyMethod. You need to pass in a function pointing to the log and group you want to use as well.

@LoggyMethod((t) => log.global(t))
testMethod() {
  for (let index = 0; index < 1000000; index++) {
      const text = String(index);
      const number = +text;
  }
}

This decorator admits the following options, which, again, are pretty self-explanatory.

{
  logTime: true,
  logCalls: false,
  logContext: false,
  enable: true,
}

Addionally, it is possible to customize the log level colors as well as the separator between the group name and the actually log text. You need to pass in another argument while creating a new instace of Loggy.

{
  separator: '#',
  debug: 'background: white; color: black;',
  log: 'background: purple; color: white;',
  info: 'background: blue; color: white;',
  warn: 'background: orange; color: black;',
  error: 'background: red; color: white;',
};