Git Product home page Git Product logo

cnsl's Introduction

cnsl's People

Contributors

magnal avatar dependabot[bot] avatar manuel-lang-fnt avatar

Stargazers

Antoine Walter avatar timelyportfolio avatar

Watchers

timelyportfolio avatar James Cloos avatar  avatar

cnsl's Issues

Scoped cnsl calls

The more cnsl is used within an application, the more logs are shown in the browser console. To have the ability to only show logs for specific parts of the application.

The scope could be added for each cnsl call or per file/class.

cnsl(CnslScopes.ANY_SCOPE).log(...);
cnsl(CnslScopes.ANY_SCOPE).log(...);
// or
cnsl = cnsl(CnslScopes.ANY_SCOPE);
cnsl.log(...);
cnsl.log(...);

This scope (or array of scopes) could be shown in the console to have the ability to filter it. Next step could be a api to only activate specific scopes.

Groups in groups

Due to the buffered logs we lost the ability to have groups in groups. Console api supports groups in groups, which is a nice feature. It should be supported from cnsl as well.

Proposal for an enhanced use of decorators

@cnslClass() // tracks instances of classes (limit of # of instances can be passed, shows warn and error if limit is reached)
export class SampleClass
{
  @cnsl()
  private cnsl:Cnsl;

  constructor()
  {
    // scoped cnsl
    this.cnsl;
    // global cnsl
    cnsl;

    // create scoped cnsl manually
    let anotherScopeCnsl:Cnsl = cnsl.scoped();
  }

  @cnslMethod() // tracks params and return values, counts number of runs, show warn and error when limit is reached
  public anyMethod(param:string, @cnslGroup('') cnsl:Cnsl):string
  {
    this.cnsl.group((cnsl:Cnsl) =>
    {

    });

    cnsl.group((cnsl:Cnsl) => {
      cnsl;
    });
  }
}

cnsl is setting up cnsl instance with the scope of the current class.

cnslGroup is setting up a cnsl group instance with the scope of the current class and method (group opens on method start and closes on method end).

cnslClass is tracking instances of the class.

cnslMethod is tracking calls of the method.

Group creation can be simplified

What I have in mind is something like this:

cnsl.group('This is my group name', (cnsl:Cnsl) => 
{
  cnsl.debug('Grouped debug log');
});

Group creation and completion is done automatically, it's easier to use and it looks nicer.

Update:
Additionally, the api could be changed to enable collapsed groups via a flag or config object:

cnsl.group('This is my group name', true, (cnsl:Cnsl) => 
{
  cnsl.debug('Grouped debug log');
});

// or

cnsl.group('This is my group name', {collapsed: true}, (cnsl:Cnsl) => 
{
  cnsl.debug('Grouped debug log');
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.