GithubHelp home page GithubHelp logo

Comments (2)

czioutas avatar czioutas commented on April 27, 2024

I updated the reproduce repo with a logSafe function which essentially checks if context is undefined before sending it to super.
I assumed that this functionality would be handled from the core logic.
app-logger.service.ts

  logSafe(message: any, context?: string) {
    const modifiedMessage = `${message} test`;

    console.log(modifiedMessage, context);

    if (context === undefined) {
      super.log(modifiedMessage);
    } else {
      super.log(modifiedMessage, context);
    }
  }

from nest.

kamilmysliwiec avatar kamilmysliwiec commented on April 27, 2024

log(message: any, context?: string): void;
log(message: any, ...optionalParams: [...any, string?]): void;
log(message: any, ...optionalParams: any[]) {
if (!this.isLevelEnabled('log')) {
return;
}
const { messages, context } = this.getContextAndMessagesToPrint([
message,
...optionalParams,
]);
this.printMessages(messages, context, 'log');
}

Since log() method lets you pass multiple messages (separated by ,) to write to the stdout, second parameter won't necessarily represent a "context" (https://github.dev/nestjs/nest/blob/033f18161fb4d391aab0dac22f71209b97c94993/packages/common/services/console-logger.service.ts#L295) - that's why undefined is logged down too. While this may not be the most straightforward, we can't really do anything on our side without introducing a breaking change

from nest.

Related Issues (20)

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.