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

improve logging #767

Merged
merged 4 commits into from
Jun 1, 2024
Merged

improve logging #767

merged 4 commits into from
Jun 1, 2024

Conversation

ermalkaleci
Copy link
Collaborator

TODO: another PR to add colors
Screenshot 2024-05-30 at 11 37 09 PM

process.platform === 'win32' ? ['-', '\\', '|', '/'] : ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
let index = 0

const clearStatus = _.debounce(() => process.stdout.clearLine(1), 500, { trailing: true })
Copy link
Member

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?

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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

this.#apiHooks.fetching = fetching
}

fetching = _.throttle(
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That work as well

Copy link
Member

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

@ermalkaleci ermalkaleci requested a review from xlc June 1, 2024 08:26
@xlc xlc enabled auto-merge (squash) June 1, 2024 08:43
@ermalkaleci ermalkaleci changed the title improve logging & add fetch process indicator improve logging Jun 1, 2024
@xlc xlc merged commit 87458ac into AcalaNetwork:master Jun 1, 2024
6 checks passed
@ermalkaleci ermalkaleci deleted the improve-logging branch June 1, 2024 21:05
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