-
Notifications
You must be signed in to change notification settings - Fork 92
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
improve logging #767
improve logging #767
Conversation
packages/chopsticks/src/logger.ts
Outdated
process.platform === 'win32' ? ['-', '\\', '|', '/'] : ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'] | ||
let index = 0 | ||
|
||
const clearStatus = _.debounce(() => process.stdout.clearLine(1), 500, { trailing: true }) |
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.
this could clear other logs?
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.
It clear from cursor to right. Best explained if you run it
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.
I am asking if it is possible to have other log printed in between and this ended up of clear the other log instead
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.
no because it prints "Fetching" and moves the cursor at the beginning and the clear is done from cursor position to the right.
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.
I'm creating another PR this
packages/core/src/api.ts
Outdated
this.#apiHooks.fetching = fetching | ||
} | ||
|
||
fetching = _.throttle( |
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.
maybe we can have the throttle logic on the handler instead? so this is get called on every fetch. just to make the API less complicated
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.
That work as well
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.
the main thing about denouncing logic is that it is often we forget to clear the timer at destructor and it could cause issue for example this is used in unit tests and creating many Chopsticks instances
TODO: another PR to add colors
![Screenshot 2024-05-30 at 11 37 09 PM](https://private-user-images.githubusercontent.com/3055344/335383064-13a108de-af4f-4a05-a6be-25c993ec72fb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMzA0MzQsIm5iZiI6MTczOTIzMDEzNCwicGF0aCI6Ii8zMDU1MzQ0LzMzNTM4MzA2NC0xM2ExMDhkZS1hZjRmLTRhMDUtYTZiZS0yNWM5OTNlYzcyZmIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMjMyODU0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzVkMjIwYjBjMjU3ODhhODViYjExYWQ4YmYzZDMwZjg1OGY3Yjg4ODlkZWFlM2YzNTM0MGE1NjRjYjA1OGU0MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.bMIacevmIA6UzaESkKy30UoJqUBdNiLI3Mp9iupPNI8)