Skip to content
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

chore(#9080): adds logger shared lib #9083

Merged
merged 13 commits into from
May 6, 2024
Merged

Conversation

dianabarsan
Copy link
Member

@dianabarsan dianabarsan commented May 1, 2024

Description

#9080

Code review checklist

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.

Compose URLs

If Build CI hasn't passed, these may 404:

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

Signed-off-by: Diana Barsan <[email protected]>
Signed-off-by: Diana Barsan <[email protected]>
Signed-off-by: Diana Barsan <[email protected]>
Signed-off-by: Diana Barsan <[email protected]>
Signed-off-by: Diana Barsan <[email protected]>
Signed-off-by: Diana Barsan <[email protected]>
Signed-off-by: Diana Barsan <[email protected]>
@dianabarsan
Copy link
Member Author

Can I please have your thoughts @garethbowen ? Thanks!!

Signed-off-by: Diana Barsan <[email protected]>
Signed-off-by: Diana Barsan <[email protected]>
Signed-off-by: Diana Barsan <[email protected]>
Copy link
Member

@garethbowen garethbowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One refactor suggestion, but otherwise this is great!

shared-libs/logger/src/index.js Outdated Show resolved Hide resolved
});
},
};
module.exports = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@@ -1,19 +1,19 @@
const rewire = require('rewire');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo! Death to rewire!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! i concur!

@garethbowen
Copy link
Member

@dianabarsan One more random thought... in node services we often log like log.error("got error: %o", err) - but that won't work in the browser, right? Do we have to just be careful to not use that format in shared-libs?

@dianabarsan
Copy link
Member Author

in node services we often log like log.error("got error: %o", err)

Correct, this kind of formatting won't work in the browser. Nothing is going to break, but we won't achieve the desired result. I suppose we can continue to use this format when we know the code will only be used in nodejs - in libraries like server-checks for example.

@garethbowen
Copy link
Member

@dianabarsan What about this: https://www.npmjs.com/package/winston-transport-browserconsole ? It might mean the logging API is consistent between node and browser?

@dianabarsan
Copy link
Member Author

@dianabarsan What about this: https://www.npmjs.com/package/winston-transport-browserconsole ? It might mean the logging API is consistent between node and browser?

I've read about it. People said it bulks the browser bundle. I'll try it out though.

@dianabarsan
Copy link
Member Author

It looks like winston-transport-browserconsole it doesn't work out of the box:

image

It looks like setImmediate has been deprecated for a while: https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate and the library hasn't received any update in years. I'm reluctant to use it.

Do you think it's worth more time working out how to generalize logging in webapp in this PR?

Copy link
Member

@garethbowen garethbowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@dianabarsan dianabarsan merged commit 989c9d6 into master May 6, 2024
42 checks passed
@dianabarsan dianabarsan deleted the 8338-environment-shared-lib branch May 6, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants