You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.text('Error occurred while executing code', { color:'red', fontSize:24 })
41
-
.group(false)
42
-
.text('For more information expand the group', { color:'green' })
43
-
.line()
44
-
.text('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.')
45
-
.print();
46
-
```
47
-
48
-
## Browser support
49
-
50
-
The project supports Chrome, Firefox, Safari, Opera, IE7+.
51
-
It fallbacks to messages without styles when they are not supported.
52
-
53
-
## API
54
-
55
-
### text(text:string)
56
-
57
-
Appends a text to the current message. All styles in the current span are applied.
58
-
59
-
```javascript
60
-
console.message().text('this is equal to just calling console.log()').print();
61
-
62
-
console.message()
63
-
.text('Error: ', { color:'red' })
64
-
.text('this is more useful scenario')
65
-
.print();
66
-
```
67
-
68
-
### element(element:HTMLElement)
69
-
70
-
Adds an interactive DOM element to the output.
71
-
72
-
```javascript
73
-
console.message()
74
-
.text('Hey take a look at the page body')
75
-
.element(document.body)
76
-
.print();
77
-
```
78
-
79
-
### object(object:Object)
80
-
81
-
Adds an interactive object tree to the output.
82
-
83
-
```javascript
84
-
console.message()
85
-
.text('Hey take a look at the this object ')
86
-
.object({ firstName:'John', lastName:'Doe' })
87
-
.print();
88
-
```
89
-
90
-
### span(styles:Object)
91
-
92
-
Starts a span with particular style and all appended text after it will use the style.
93
-
94
-
```javascript
95
-
console.message()
96
-
.span({ color:'red' })
97
-
.text('this is red! ')
98
-
.span({ color:'green' })
99
-
.text('this is green! ')
100
-
.spanEnd()
101
-
.text('this is again red!')
102
-
.spanEnd()
103
-
.print();
104
-
```
105
-
106
-
### spanEnd()
107
-
108
-
Ends the current span styles and backs to the previous styles or the root if there are no other parents.
109
-
Take a look at the example above.
110
-
111
-
### group(expanded:boolean = true)
112
-
113
-
Begins a group. By default the group is expanded. Provide false if you want the group to be collapsed.
114
-
115
-
```javascript
116
-
console.message()
117
-
// pass false if you want to create a collapsed group
118
-
.group()
119
-
.text('The group header text')
120
-
.line()
121
-
.text('The group content')
122
-
.groupEnd()
123
-
.print();
124
-
```
125
-
126
-
### groupEnd()
127
-
128
-
Ends the group and returns to writing to the parent message.
129
-
130
-
```javascript
131
-
console.message()
132
-
.group(false)
133
-
.text('group')
134
-
.groupEnd()
135
-
.text('Outside of group')
136
-
.print();
137
-
```
138
-
139
-
### line()
140
-
141
-
Adds a new line to the output.
142
-
143
-
```javascript
144
-
console.message()
145
-
.text('first line')
146
-
.line()
147
-
.text('second line')
148
-
.print();
149
-
```
150
-
151
-
### print()
152
-
153
-
Prints the message to the console.
154
-
Every message chaining should end with `print`. No `print()` call no message.
0 commit comments