Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Two small suggestions for improvements #4

Open
NiklasA opened this issue Jan 3, 2018 · 0 comments
Open

Two small suggestions for improvements #4

NiklasA opened this issue Jan 3, 2018 · 0 comments

Comments

@NiklasA
Copy link

NiklasA commented Jan 3, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant