Giter Site home page Giter Site logo

astcenc's Introduction

@cameronhunter/debug-logger

A TypeScript decorator for classes that logs all method usages using the debug package. Logging is enabled using the DEBUG environment variable โ€“ see the debug package for details.

Examples

Simple usage

The decorator can be used directly and it will log to a namespace matching the class name it is decorating. An execution of new HelloWorld().main('World') below will result in HelloWorld main("World"); being logged.

import DebugLogging from '@cameronhunter/debug-logger';

@DebugLogging
class HelloWorld {
  main(name: string) {
    console.log(`Hello ${name}!`);
  }
}

Using a custom namespace

The decorator also accepts an optional namespace that will be used in addition to the class name it is decorating. An execution of new HelloWorld().main('World') below will result in my-debug-namespace:HelloWorld main("World"); being logged.

import DebugLogging from '@cameronhunter/debug-logger';

@DebugLogging('my-debug-namespace')
class HelloWorld {
  main(name: string) {
    console.log(`Hello ${name}!`);
  }
}

Configuring a shared logger

The decorator can be preconfigured and shared. For example, we can configure a debug logger with a custom namespace and export it for use around an application. An execution of new HelloWorld().main('World') below will result in my-namespace:HelloWorld main("World"); being logged.

import DebugLogger from '@cameronhunter/debug-logger';

const CustomLogger = DebugLogger('my-namespace');

@CustomLogger
class HelloWorld {
  main(name: string) {
    console.log(`Hello ${name}!`);
  }
}

astcenc's People

Contributors

cameronhunter avatar tquetano-netflix avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

astcenc's Issues

Add Windows support

ARM provides astcenc executables for Windows 64-bit (source). We need a method to check the CPU extended features to choose the best executable to run. This post recommends using coreinfo to do so.

  • Create a @astcenc/windows-x64 package containing the relevant executables.
  • Create astcenc-windows-x64 script that uses coreinfo to determine which of the astcenc-* executables to use for the current CPU architecture/features.
  • Add @astcenc/windows-x64 as an optional dependency to astcenc.

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.