Giter VIP home page Giter VIP logo

angular-logger's People

Contributors

dependabot[bot] avatar kingofferelden avatar renovate-bot avatar renovate[bot] avatar splincode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

angular-logger's Issues

Refactor timer log

console.time("answer time");
alert("Click to continue");
console.timeLog("answer time");

add format output

LoggerModule.forRoot({
  format: ({ label, style }) => {
      const date = new Date().toLocaleString('ru-RU').replace(',', '');
      return [ `${date} ${label.toUpperCase()} `, style ];
  }
})

Decorator API

I. Logger decorator

Before

export class AppComponent implements OnInit {
    constructor(private logger: LoggerService) {}

    public ngOnInit(): void {
        this.logger.debug('hello world');
    }
}

After

export class AppComponent implements OnInit {
    @Logger() private logger: LoggerService;

    public ngOnInit(): void {
        this.logger.debug('hello world');
    }
}

II. Use only methods

Before

export class AppComponent implements OnInit {
    constructor(private logger: LoggerService) {}

    public ngOnInit(): void {
        this.logger.trace('hello world');
        this.logger.debug('hello world');
        this.logger.log('hello world');
        this.logger.warn('hello world');
        this.logger.error('hello world');
    }
}

After

export class AppComponent implements OnInit {
    @Trace() private trace: LogFn;
    @Debug() private debug: LogFn;
    @Log() private log: LogFn;
    @Warn() private warn: LogFn;
    @Error() private error: LogFn;

    public ngOnInit(): void {
        this.trace('hello world');
        this.debug('hello world');
        this.log('hello world');
        this.warn('hello world');
        this.error('hello world');
    }
}

III. Group, GroupCollapsed

Before

export class AppComponent implements OnInit {
    constructor(private readonly logger: LoggerService) {}

    public ngOnInit(): void {
        this.logger.group(
            'Show trace in opened group',
            ({ trace }: LoggerService): void => {
                for (let i: number = 0; i < 20; i++) {
                    trace( 'trace is worked', i);
                }
            }
        );
    }
}

After

export class AppComponent implements OnInit {
    @Trace() private trace: LogFn;
    
    @Group('Show trace in opened group') public ngOnInit(): void {
      for (let i: number = 0; i < 20; i++) {
         this.trace('trace is worked', i);
      }
    }
}

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.