@@ -10,6 +10,7 @@ exports.formatArgs = formatArgs;
10
10
exports . save = save ;
11
11
exports . load = load ;
12
12
exports . useColors = useColors ;
13
+ exports . hrtime = hrtimeInit ( ) ;
13
14
exports . storage = 'undefined' != typeof chrome
14
15
&& 'undefined' != typeof chrome . storage
15
16
? chrome . storage . local
@@ -80,20 +81,28 @@ exports.formatters.j = function(v) {
80
81
* @api public
81
82
*/
82
83
83
- function formatArgs ( args ) {
84
+ function formatArgs ( args , section ) {
84
85
var useColors = this . useColors ;
85
86
86
87
args [ 0 ] = ( useColors ? '%c' : '' )
87
88
+ this . namespace
88
89
+ ( useColors ? ' %c' : ' ' )
90
+ + ( section ? ( section . title + ( useColors ? ' %c' : ' ' ) ) : '' )
89
91
+ args [ 0 ]
90
92
+ ( useColors ? '%c ' : ' ' )
91
- + '+' + exports . humanize ( this . diff ) ;
93
+ + '+' + exports . humanize ( this . diff )
94
+ + ( section && section . complete ? ( '%c (delta ' + ( useColors ? '%c+' : '+' ) + exports . humanize ( section . deltaTime ) + ( useColors ? '%c)' : ')' ) ) : '' ) ;
92
95
93
96
if ( ! useColors ) return ;
94
97
95
98
var c = 'color: ' + this . color ;
96
- args . splice ( 1 , 0 , c , 'color: inherit' )
99
+ var inherit = 'color: inherit' ;
100
+
101
+ if ( section ) {
102
+ args . splice ( 1 , 0 , c , inherit + '; font-weight: bold' , 'font-weight: normal' ) ;
103
+ } else {
104
+ args . splice ( 1 , 0 , c , inherit ) ;
105
+ }
97
106
98
107
// the final "%c" is somewhat tricky, because there could be other
99
108
// arguments passed either before or after the %c, so we need to
@@ -110,7 +119,11 @@ function formatArgs(args) {
110
119
}
111
120
} ) ;
112
121
113
- args . splice ( lastC , 0 , c ) ;
122
+ if ( section && section . complete ) {
123
+ args . splice ( lastC - 2 , 0 , c , inherit , c , inherit ) ;
124
+ } else {
125
+ args . splice ( lastC , 0 , c ) ;
126
+ }
114
127
}
115
128
116
129
/**
@@ -166,6 +179,22 @@ function load() {
166
179
return r ;
167
180
}
168
181
182
+ /**
183
+ * Browser implementation of hrtime().
184
+ *
185
+ * Follows the spec outlined in debug.begin() (see debug.js).
186
+ *
187
+ * If the browser has support for `window.performance.now()`,
188
+ * then it is used. Otherwise, it falls back to `Date.now()`.
189
+ */
190
+ function hrtimeInit ( ) {
191
+ var nowfn = window && window . performance && window . performance . now ? window . performance . now . bind ( window . performance ) : Date . now ;
192
+ return function ( prev ) {
193
+ var now = nowfn ( ) ;
194
+ return prev ? ( now - prev ) : now ;
195
+ } ;
196
+ }
197
+
169
198
/**
170
199
* Enable namespaces listed in `localStorage.debug` initially.
171
200
*/
0 commit comments