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

Move logger to common-universal #691

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

b-tarczynski
Copy link
Contributor

Additionally we can swap ms package with pretty-ms.
The differences are:

  • UnixTime.ONE_YEAR() changes to '1y'
  • UnixTime(UnixTime.ONE_YEAR() - UnixTime.ONE_HOUR()) changes to '364d 23h'

What do you think about swapping ms package? It's used only in UnixTime

Copy link

vercel bot commented Mar 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 6, 2025 1:22pm
spark-app-production ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 6, 2025 1:22pm
spark-app-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 6, 2025 1:22pm

Copy link

github-actions bot commented Mar 6, 2025

📦 Size Report

Path Size Diff
JS 1.28 MB 2 B (+0.01% 🔺)
CSS 24.35 KB 0 B (0%)

@@ -28,7 +28,8 @@ export default defineConfig({
// nodePolyfills needs to be first
nodePolyfills({
// buffer is needed when connecting with a coinbase wallet installed on a phone
include: ['buffer'],
// util and path is needed for common-universal's logger
include: ['buffer', 'util', 'path'],
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need these? I would prefer not to use node apis in browser

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Util is used for inspect to format objects, path isn't doing anything in browser. I tried to conditionally import a path depending if that's a browser or not, but nothing worked - logger would have to be async which we don't want to do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyway using util polyfill breaks frontend tests, so probably we need to figure out something else

@@ -38,7 +34,7 @@ export class Logger implements ILogger {
service: options.service,
tag: options.tag,
utc: options.utc ?? false,
cwd: options.cwd ?? process.cwd(),
cwd: options.cwd,
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use process when not in browser?

Copy link
Contributor Author

@b-tarczynski b-tarczynski Mar 6, 2025

Choose a reason for hiding this comment

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

In browser we can, but it returns undefined which is not compatible with process.cwd() return type. The cwd parameter is optional in the options.

We use process.cwd() in PrettyLogger in common-node

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before we were using node:path's join function after obtaining cwd, that's why I haven't done this in common-universal

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.

3 participants