bajo 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/boot/helper/print.js +4 -1
- package/boot/lib/bora.js +7 -2
- package/package.json +1 -1
package/boot/helper/print.js
CHANGED
|
@@ -20,6 +20,7 @@ function format (...args) {
|
|
|
20
20
|
const { ns, msg, params, opts } = prep(args)
|
|
21
21
|
if (!msg) return ''
|
|
22
22
|
const i18n = get(this, 'bajoI18N.instance')
|
|
23
|
+
const dayjs = get(this, 'bajo.helper')
|
|
23
24
|
if (i18n) {
|
|
24
25
|
if (isPlainObject(params[0])) {
|
|
25
26
|
const ctx = merge({}, params[0] ?? {}, { ns })
|
|
@@ -34,7 +35,9 @@ function format (...args) {
|
|
|
34
35
|
}
|
|
35
36
|
return i18n.t(msg, { ns, pkg: opts.pkg, postProcess: 'sprintf', sprintf: params })
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
let text = sprintf(msg, ...params)
|
|
39
|
+
if (opts.showDatetime && dayjs) text = `[${dayjs().toISOString()}] ${text}`
|
|
40
|
+
return text
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
const print = {
|
package/boot/lib/bora.js
CHANGED
|
@@ -36,9 +36,14 @@ class Bora {
|
|
|
36
36
|
if (isPlainObject(args[0])) text = i18n.t(text, args[0])
|
|
37
37
|
else text = i18n.t(text, { ns: this.ns, postProcess: 'sprintf', sprintf: args })
|
|
38
38
|
} else text = sprintf(text, ...args)
|
|
39
|
+
let opts = last(args)
|
|
40
|
+
if (!isPlainObject(opts)) opts = {}
|
|
39
41
|
const elapsed = dayjs().diff(this.startTime, 'second')
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
+
const texts = []
|
|
43
|
+
if (this.opts.showDatetime || opts.showDatetime) texts.push('[' + dayjs().toISOString() + ']')
|
|
44
|
+
if (this.opts.showCounter || opts.showCounter) texts.push('[' + secToHms(elapsed) + ']')
|
|
45
|
+
texts.push(text)
|
|
46
|
+
this.ora.text = texts.join(' ')
|
|
42
47
|
}
|
|
43
48
|
return this
|
|
44
49
|
}
|