-
-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom logger for nestjs-hasura #351
Comments
I think we can create a factory for the logger so that you can use your own logger like the official Nestjs core package does |
After investigating this request I have found no need on having a custom logger as a config property, there's a better way on having a consistent logger across the nestjs app which is overriding nestjs default logger. https://docs.nestjs.com/v7/techniques/logger#extend-built-in-logger If this doesn't help then I can re-evaluate this request Here's an example of the custom logger that I've made just so you can see the logs are passed into my custom stream |
My code does use async function bootstrap() {
const logger = WinstonModule.createLogger(loggerOptions);
const app = await NestFactory.create(AppModule, {
logger,
});
app.useLogger(logger);
const options = new DocumentBuilder()
.setTitle('Webhooks API')
.setDescription('Webhooks API')
.setVersion(process.env.npm_package_version)
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
app.use(helmet());
app.enableCors();
const port = process.env.PORT || 4004;
await app.listen(port);
logger.log(`Application ready on port ${port}`, 'NestApplication');
} Here's what I get: [2022-01-13T01:28:32.245Z][NestFactory][info] Starting Nest application...
[2022-01-13T01:28:32.267Z][InstanceLoader][info] ConfigHostModule dependencies initialized
[2022-01-13T01:28:32.267Z][InstanceLoader][info] DiscoveryModule dependencies initialized
[2022-01-13T01:28:32.267Z][InstanceLoader][info] TerminusModule dependencies initialized
[2022-01-13T01:28:32.426Z][InstanceLoader][info] StripeModule dependencies initialized
[2022-01-13T01:28:32.426Z][InstanceLoader][info] ConfigModule dependencies initialized
[2022-01-13T01:28:32.426Z][InstanceLoader][info] ConfigModule dependencies initialized
[2022-01-13T01:28:32.427Z][InstanceLoader][info] FirebaseModule dependencies initialized
[2022-01-13T01:28:32.427Z][InstanceLoader][info] AppModule dependencies initialized
[2022-01-13T01:28:32.427Z][InstanceLoader][info] HasuraModule dependencies initialized
[2022-01-13T01:28:32.428Z][InstanceLoader][info] HealthchecksModule dependencies initialized
[2022-01-13T01:28:32.950Z][RoutesResolver][info] HealthchecksController {/healthcheck}:
[2022-01-13T01:28:32.952Z][RouterExplorer][info] Mapped {/healthcheck, GET} route
[2022-01-13T01:28:32.952Z][RouterExplorer][info] Mapped {/healthcheck/auth, GET} route
[2022-01-13T01:28:32.952Z][RoutesResolver][info] EventHandlerController {/hasura}:
[2022-01-13T01:28:32.953Z][RouterExplorer][info] Mapped {/hasura/events, POST} route
[Nest] 5668 - 2022-01-12, 5:28:32 p.m. [HasuraModule] Initializing Hasura Module
[Nest] 5668 - 2022-01-12, 5:28:32 p.m. [HasuraModule] Discovered 3 hasura event handlers
[Nest] 5668 - 2022-01-12, 5:28:32 p.m. [HasuraModule] Registering hasura event handlers from ProvidersService
[Nest] 5668 - 2022-01-12, 5:28:32 p.m. [HasuraModule] Registering hasura event handlers from MembershipsService
[2022-01-13T01:28:32.977Z][NestApplication][info] Nest application successfully started
[2022-01-13T01:28:32.980Z][NestApplication][info] Application ready on port 4004 |
For some reason, I installed |
Confirmed, installing
I'm gonna close this for now 👍🏻 |
The issue is back after updating to the latest versions:
|
@foxted I have merged a PR that reverts the change from using |
Thanks @underfisk, appreciate it 🙂 |
@foxted Can you try out the new release |
Just updated to the new release and it works again :) Thank you @WonderPanda 🚀 |
Hi there,
Is there a way to override the default logger in nestjs-hasura? Would like to extend it to use our custom logger but I don't really know how.
We are sending json logs to Google Cloud Logging, would love to use the same format, but the custom logger isn't picked up by the module. Ex.:
We can see in the example that the logs are shown using Nest.js default logger instead.
Thanks!
The text was updated successfully, but these errors were encountered: