Comments (14)
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.
Hi, are you able to setup a minimal repository example?
from nest-winston.
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.
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.
@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.
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.
I've improved the README, can you both take a look at it and see if the isssue persist?
from nest-winston.
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.
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.
Thanks, it's a great idea. Should I use the nest cli right?
from nest-winston.
As you want! But the nestcli can help you generate quickly a base app 👌
from nest-winston.
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:
from nest-winston.
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.
@Nightbr you're right, look at #324
from nest-winston.
Related Issues (20)
- "Unknown logger level" error when used for bootstraping HOT 3
- Nest can't resolve dependencies HOT 8
- Default context per service (configurable injection scope) HOT 3
- Passing winston logger instance to forRoot doesn't work HOT 2
- [Bug]: Creating multiple winston modules using child winston loggers use the last created winston module when using the nestjs Logger constructor HOT 2
- Adding "level" argument to log method HOT 2
- NestLike ConsoleFormat always contains stringifiedMeta and essentially logs message twice HOT 7
- LoggerService interface changed with Nest v8 HOT 2
- Is there a way to create a child logger? HOT 2
- How can I pass json attributes into the logger? HOT 3
- Support for @nestjs/common 10.0.0 in Peer Dependencies HOT 2
- [Question]: Should documentation be updated? HOT 8
- [Feature]: Support string-interpolation HOT 1
- [Question]: How to get trace_id ? HOT 4
- [Feature]: add fatal level HOT 6
- [Question]: How can I access a request scope injectable when replacing the Nest logger (including boostrap) ? HOT 2
- [Question]: Winston creates file but does not save to it
- [Question]: processing optional arguments is not consistent with Nest HOT 3
- [Bug]: Redundant Stack Information in Error Logs HOT 2
- [Bug]: Code for v1.9.5 of Nest Winston not in NPM HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nest-winston.