-
Notifications
You must be signed in to change notification settings - Fork 2
fix: logger initialization, async/await usage, and error handling #262
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,14 +11,14 @@ import { Logger } from "@uma/logger"; | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| dotenv.config(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const logger = Logger; | ||||||||||||||||||||||
| const logger = new Logger(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| async function run() { | ||||||||||||||||||||||
| const { APP } = process.env; | ||||||||||||||||||||||
| assert(APP, 'Specify the application to start with "APP=appname pnpm start"'); | ||||||||||||||||||||||
| switch (APP) { | ||||||||||||||||||||||
| case "template": | ||||||||||||||||||||||
| void (await Template.Main(process.env)); | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When you write So, if you choose to keep If the goal is to avoid linter warnings and you don’t need the result of the call, then keeping
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey! This is correct - we're intentionally discarding the output |
||||||||||||||||||||||
| await Template.Main(process.env); | ||||||||||||||||||||||
| return "Example template app running"; | ||||||||||||||||||||||
| case "indexer": | ||||||||||||||||||||||
| void (await Indexer.Main(Indexer.envToConfig(process.env), logger)); | ||||||||||||||||||||||
|
|
@@ -36,4 +36,6 @@ async function run() { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| run() | ||||||||||||||||||||||
| .then((x) => x && logger.info({ at: "app", message: x })) | ||||||||||||||||||||||
| .catch(console.log); | ||||||||||||||||||||||
| .catch((error) => { | ||||||||||||||||||||||
| logger.error(error); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
Comment on lines
+39
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thoughts on something like this? Otherwise we may have issues with the UMA/logger package
Suggested change
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm - I think
Logger(where we get it from) is an already instantiated extension ofwinston. I think adding thenewwould remove the slack/pager duty specific transports.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.