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

Two small suggestions for improvements #4

Open
@NiklasA

Description

@NiklasA

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions