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

Color output for commands #179

Closed
mmarchini opened this issue Mar 21, 2018 · 6 comments
Closed

Color output for commands #179

mmarchini opened this issue Mar 21, 2018 · 6 comments

Comments

@mmarchini
Copy link
Contributor

While trying to come up with a comprehensible output format for #115, I decided to play with colors in llnode commands outputs:

asciicast

Not entirely sure if this is something we want to have on llnode since we'll need to detect if the terminal supports color (I have no idea how to do that), but if we decide to have it I can open a PR with it.

@joyeecheung
Copy link
Member

We can use an environment variable or a command line flag to control the colors (for example to work around tests or other cases where we need to redirect the output to a file)

@joyeecheung
Copy link
Member

joyeecheung commented Mar 22, 2018

BTW I have this when I need to write the output of a command to a file when it's too long to read in the terminal (e.g. the result of v8 findjsinstance)

~/.lldb/to_file.py

import lldb
import sys

def to_file(debugger, command, result, dict):
    # Change the output file to a path/name of your choice
    f = open("/tmp/temp-lldb-output.txt", "w")
    debugger.SetOutputFileHandle(f, True)
    # Change command to the command you want the output of
    debugger.HandleCommand(command)
    f.close()
    print >> sys.stderr, 'Written to /tmp/temp-lldb-output.txt'
    debugger.SetOutputFileHandle(sys.stdout, True)

~/.lldbinit

comma script import ~/.lldb/to_file.py
comma script add -f to_file.to_file to_file

@mmarchini
Copy link
Contributor Author

mmarchini commented Mar 22, 2018

Ohh, nice script! I usually do lldb node -c core -b -o "v8 findjsinstances" > output.txt, but I need to quit lldb to use this :/.

I was thinking: we could have something like v8 settings set color on (off by default), and then use the llnode script to determine if the terminal is color-friendly. If it is, turn on color with --one-line "v8 settings set color on" before starting lldb. What do you think?

Edit: This would also make it easier to have an environment variable and a flag, as you suggested 😄

@joyeecheung
Copy link
Member

@mmarchini SGTM

@gibfahn
Copy link
Member

gibfahn commented Mar 26, 2018

We can use an environment variable or a command line flag to control the colors (for example to work around tests or other cases where we need to redirect the output to a file)

If we do this (which I think we should) I think the standard thing I've seen is to set --color=auto, which outputs color if the stdout/stderr is a tty, and not otherwise. Then you can have always or never as options. That seems to be what other programs I've used tend to have.

Drieger added a commit to Drieger/llnode that referenced this issue Aug 20, 2018
To make visualization easier, objects types, properties and addresses
will be colorized. Using `rang` library color pallete, the current
definition is:
* cyan for addresses
* magenta for objects being inspected
* yellow for types
* bold yellow for objects properties

Fixes: nodejs#179
@Drieger
Copy link
Contributor

Drieger commented Aug 21, 2018

I started working on a prototype, using the rang library. Any thoughts and ideas are welcome. The proposed flag is still missing, I just need some guidance to know if current work is ok.

Current work: master...Drieger:start_colorization

Drieger added a commit to Drieger/llnode that referenced this issue Aug 23, 2018
To make visualization easier, objects types, properties and addresses
will be colorized. Using `rang` library color pallete, the current
definition is:
* cyan for addresses
* magenta for objects being inspected
* yellow for types
* bold yellow for objects properties

Fixes: nodejs#179
Drieger added a commit to Drieger/llnode that referenced this issue Aug 27, 2018
To make visualization easier, objects types, properties and addresses
will be colorized. Using `rang` library color pallete, the current
definition is:
* cyan for addresses
* magenta for objects being inspected
* yellow for types
* bold yellow for objects properties

Fixes: nodejs#179

Colorize findrefs output
Drieger added a commit to Drieger/llnode that referenced this issue Sep 4, 2018
To make visualization easier, objects types, properties and addresses
will be colorized. Using `rang` library color pallete, the current
definition is:
* cyan for addresses
* magenta for objects being inspected
* yellow for types
* bold yellow for objects properties

Fixes: nodejs#179

Colorize findrefs output
Drieger added a commit to Drieger/llnode that referenced this issue Sep 18, 2018
To make visualization easier, objects types, properties and addresses
will be colorized. Using `rang` library color pallete, the current
definition is:
* cyan for addresses
* magenta for objects being inspected
* yellow for types
* bold yellow for objects properties

Fixes: nodejs#179

Colorize findrefs output
Drieger added a commit to Drieger/llnode that referenced this issue Sep 26, 2018
To make visualization easier, objects types, properties and addresses
will be colorized. Using `rang` library color pallete, the current
definition is:
* cyan for addresses
* magenta for objects being inspected
* yellow for types
* bold yellow for objects properties

Fixes: nodejs#179

Colorize findrefs output
mmarchini pushed a commit to mmarchini/llnode that referenced this issue Oct 4, 2018
To make visualization easier, objects types, properties and addresses
will be colorized. Using `rang` library color pallete, the current
definition is:
* cyan for addresses
* magenta for objects being inspected
* yellow for types
* bold yellow for objects properties

Fixes: nodejs#179

Colorize findrefs output
hyj1991 pushed a commit to aliyun-node/llnode that referenced this issue Oct 11, 2018
To make visualization easier, objects types, properties and addresses
will be colorized. Using `rang` library color pallete, the current
definition is:
* cyan for addresses
* magenta for objects being inspected
* yellow for types
* bold yellow for objects properties

Fixes: nodejs#179

Colorize findrefs output

PR-URL: nodejs#225
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants