Giter Club home page Giter Club logo

Comments (14)

Nightbr avatar Nightbr commented on May 24, 2024 1

Yep sure, for example in nestjs/terminus, they have created a folder sample be can be called examples IMO. And in it you have 1 folder per example. In each folder, you have a minimal nestjs app with the configuration you want to demonstrate.

For this module, I think we could have multiple examples such as:

  • Basic Module configuration (what is explain in Quick start)
  • Async Configuration (coupled with the ConfigModule could be a nice real life example)
  • Use Logger in Bootstrap
  • Configure NestLike formatter
  • ...

See https://github.com/nestjs/terminus/tree/master/sample

Maybe create a Pull Request and I'm ok to review & complete the PR if you want.

from nest-winston.

gremo avatar gremo commented on May 24, 2024

Hi, are you able to setup a minimal repository example?

from nest-winston.

MatthewPeterGreen avatar MatthewPeterGreen commented on May 24, 2024

Hi, no problem. I created a barebones project to illustrate the problem. You just need to run it to see the error.
https://github.com/MatthewPeterGreen/nest-winston-issue

from nest-winston.

Nightbr avatar Nightbr commented on May 24, 2024

Like in this issue #275, I get the logger in main.ts with const logger: Logger = app.get(WINSTON_MODULE_NEST_PROVIDER); in it has fixed the issue. Hope it helps.

  await app.listen(port, host, () => {
    const address = configService.get('apiUrl');
    const logger: Logger = app.get(WINSTON_MODULE_NEST_PROVIDER);
    logger.setContext('Main');
    logger.log('Listening at ' + address);
    logger.log('GraphQL at ' + address + '/graphql');
  });

from nest-winston.

gremo avatar gremo commented on May 24, 2024

@Nightbr good catch!

I can't understand - however - why passing the logger option isn't working, while getting from the service container solved the issue. Any clue? I may update the documentation if we find the exact reason why isn't working.

from nest-winston.

Nightbr avatar Nightbr commented on May 24, 2024

Seems the module initialized the instance so when you override the default logger init with app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));. you need to get the logger with the correct Token WINSTON_MODULE_NEST_PROVIDER otherwise the logger is not defined.

from nest-winston.

gremo avatar gremo commented on May 24, 2024

I've improved the README, can you both take a look at it and see if the isssue persist?

from nest-winston.

Nightbr avatar Nightbr commented on May 24, 2024

Seems good to me, perhaps a bit complex for new User. Maybe we could create some nestjs boilerplate example with the different configuration? In the code base in an example folder.

from nest-winston.

gremo avatar gremo commented on May 24, 2024

Thanks for your feedback. Yes I could create a boilerplate code, but I don't know the conventions about it... can you send me some example (maybe other projects)?

from nest-winston.

gremo avatar gremo commented on May 24, 2024

Thanks, it's a great idea. Should I use the nest cli right?

from nest-winston.

Nightbr avatar Nightbr commented on May 24, 2024

As you want! But the nestcli can help you generate quickly a base app 👌

from nest-winston.

gremo avatar gremo commented on May 24, 2024

Seems I can't. When running the sample app under the "sample" folder of this project, it doesn't work. I think is something about the TypeScript config (and types conflict). It works when I move the sample outside:

nest

from nest-winston.

Nightbr avatar Nightbr commented on May 24, 2024

Could you create a Pull Request where we can see the code & discuss about this, it will be better to not overflow this issue & be able to see your code & changes. Thanks!

from nest-winston.

gremo avatar gremo commented on May 24, 2024

@Nightbr you're right, look at #324

from nest-winston.

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.