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 | if (this.internal) {
|
20 | params.push(yellow('(i)'))
|
21 | }
|
22 | } else {
|
23 | params.push(gray(this.method), gray(this.url))
|
24 | }
|
25 | params.push(text.join(' '))
|
26 | method(...params)
|
27 | }
|