1 | 'use strict'
|
2 |
|
3 | const { gray, magenta, red, yellow } = require('./detect/colors')
|
4 | const { log, error } = require('./console')
|
5 |
|
6 | module.exports = function (type, showId, ...text) {
|
7 | let method
|
8 | const params = []
|
9 | if (type === 'ERROR') {
|
10 | method = error
|
11 | params.push(red(type))
|
12 | } else {
|
13 | method = log
|
14 | params.push(magenta(type))
|
15 | }
|
16 | if (showId) {
|
17 | const id = this.id.toString(16).toUpperCase()
|
18 | params.push(yellow(id.padStart(Math.max(4, id.length), '0')))
|
19 | } else {
|
20 | params.push(gray(this.method), gray(this.url))
|
21 | }
|
22 | params.push(text.join(' '))
|
23 | method(...params)
|
24 | }
|