Skip to content

Pretty print console logs #443

@RubenSandwich

Description

@RubenSandwich

Describe the Feature

Now that console.log is forwarded to the CLI, we should think about formatting those logs to be easily readable in the terminal.

Possible Implementations

Here is an idea of displaying arrays and objects to the console using some basic ASCII graphics. (The format below is loosely based upon console.table and csvkit.)

I tried to make to design this formatting style with nesting in mind, as it is very common to nest JS objects.

console.log([true, false]);

(index) | Values
0       | true
1       | false

console.log({firstName: "Erica", lastName: "Smith"});

(index)    | Values
firstName  | "Erica"
lastName   | "Smith"

console.log([{firstName: "Monica", lastName: "Johnson"}, {firstName: "Erica", lastName: "Smith"}]);

(index) | firstName | lastName
0       | "Monica"  | "Johnson"
1       | "Erica"   | "Smith"

console.log([22, {firstName: "Erica", lastName: "Smith"}, 34]);

(index) | Values
0       | 22
1       | firstName: "Erica"
        | lastName: "Smith"
2       | 34

Related Issues

Log console invocations to the terminal

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions