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

Implement console.groupCollapsed #1452

Merged
merged 2 commits into from
Jan 6, 2019

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Jan 3, 2019

depends on #1363.

This PR implements console.groupCollapsed as discussed in #1355 and #1363.
When groupCollapsed is called, console goes to 'collapsed mode' and stop printing newlines on logging methods. When further group/groupCollapsed methods are called, console keeps the collapsed mode. When groupEnd which corresponds to the first groupCollapsed call is called, console gets out of 'collapsed mode'.


remaining tasks (all done):

  • use groupCollapsed in testing later in deno_std
  • test case of console.error with console.group

@kt3k kt3k force-pushed the feature/console-group-collapsed branch 3 times, most recently from c9d132c to 861a7e1 Compare January 3, 2019 20:27
- add console.group & console.groupEnd function
- add console.group & console.groupEnd test
- fix group when log info contains \n
@kt3k kt3k force-pushed the feature/console-group-collapsed branch from 861a7e1 to fd3a409 Compare January 3, 2019 20:37
@kt3k kt3k changed the title WIP Implement console.groupCollapsed Implement console.groupCollapsed Jan 3, 2019
This implementation of groupCollapsed is intentionally different
from the spec defined by whatwg. See the conversation in denoland#1355
and denoland#1363.
@kt3k kt3k force-pushed the feature/console-group-collapsed branch from fd3a409 to e798648 Compare January 3, 2019 20:48
}
if (this.collapsedAt != null && this.collapsedAt >= this.indentLevel) {
this.collapsedAt = null;
this.log(); // When the collapsed state ended, outputs a sinle new line.
Copy link
Member

Choose a reason for hiding this comment

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

Why not use deno.stdout.write ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this class seems using PrintFunc for any output. Do you think we should use deno.stdout/deno.stderr for any output of console's methods?

Copy link
Member Author

@kt3k kt3k Jan 5, 2019

Choose a reason for hiding this comment

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

@ry I tried to replace printFunc calls with stdout/stderr calls, but I realized that stdout.write is async function and not usable as replacement of printFunc (libdeno.print). Probably we need to have sync version of write first. How do you think?

ref: kt3k@1e9bd29

Copy link
Member

Choose a reason for hiding this comment

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

Right - makes sense - I forgot that the writes to stdout/err are non-blocking.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM - thanks @kt3k !

@ry ry merged commit cae71ed into denoland:master Jan 6, 2019
@kt3k kt3k deleted the feature/console-group-collapsed branch January 7, 2019 01:33
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.

None yet

3 participants