0.0.3 • Published 4 years ago

@dekor/logger v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@dekor/logger

npm version npm download monthly npm download total npm dependents npm license pp install size github commit last github commit total

//: <> (Shields)

//: <> (Link)

A decorator that logs the method or get property when it is called

Install

$ npm install @dekor/logger

Logger vs LoggerLegacy

For those who use @babel/plugin-proposal-decorators:

Usage - stage 2 mode

import { Logger } from '@dekor/logger'
// if the class contains private field
// import { LoggerLegacy } from '@dekor/logger'

const logger = Logger('decorator:logger')


class Point {
  constructor(x, y) { this.x = x; this.y = y }

  @logger
  get distance() { return Math.sqrt(this.x ** 2 + this.y ** 2) }
}

const p = new Point(3, 4)
p.distance |> console.log

// console outputs:
// > [decorator:logOnCall] 18:29:49.008 calling property Point.distance
// > 10

Meta

LICENSE (MIT)