GithubHelp home page GithubHelp logo

strongloop-archive / loopback4-example-log-extension Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 36 KB

An example repo showing how to write a complex log extension

Home Page: https://github.com/strongloop/loopback-next/tree/master/packages/example-log-extension

loopback4-example-log-extension's People

Contributors

bajtos avatar virkt25 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

b-admike

loopback4-example-log-extension's Issues

Two small suggestions for improvements

Hi Taranveer,

I just started learning LoopBack and its concept. I just spent a few hours getting the logging extension up and running and found two things that could be improved.

  1. I think it would be very helpful, if you could add the LogSequence class to the README Example Usage part. For me (as a beginner) it wasn't 100% clear how I had to adjust my MySequence class.

  2. And the second thing is that the following call didn't worked for me.

export class ServerApplication extends LogLevelMixin(Application) {
  constructor(options?: ApplicationConfig) {
    options = Object.assign(
      {},
      {
        components: [RestComponent, LogComponent],
        // didn't worked until I added the else if in LogLevelMixin.
        **logLevel: LOG_LEVEL.DEBUG**
      },
      options
    );
    super(options);
    // alternatively, I could set it directly.
    // ** this.logLevel(LOG_LEVEL.DEBUG); **
    this.server(RestServer);
    this.setupControllers();
  }

  [...]
}

export function LogLevelMixin<T extends Constructor<any>>(superClass: T) {
  return class extends superClass {
    // A mixin class has to take in a type any[] argument!
    // tslint:disable-next-line:no-any
    constructor(...args: any[]) {
      super(...args);
      if (!this.options) this.options = {};

      if (this.options.logLevel) {
        this.logLevel(this.options.logLevel);
      } else if (args  && args.length > 0 && "undefined" !== typeof (args[0].logLevel)) {
        **this.logLevel(args[0].logLevel);**
      }
    }

  [...]
}

Thank you very much for the example, gave me a very good insight into the topic! ๐Ÿ‘

Best regards,
Niklas

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.