提交 9c96a6a1 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

fix(brolog) follow Brolog v1.0

上级 0c954681
......@@ -5,9 +5,7 @@
*
*/
// const log = require('npmlog')
import { Brolog } from 'brolog'
export let log: Brolog
import log from 'brolog'
const level = process.env['WECHATY_LOG']
......@@ -16,14 +14,11 @@ const levelRegexStr = 'silly|verbose|info|warn|error|silent'
const levelRegex = new RegExp(levelRegexStr, 'i')
if (levelRegex.test(level)) {
// log.level = level.toLowerCase()
log = new Brolog(level)
log.level(level)
log.silly('Brolog', 'WECHATY_LOG set level to %s', level)
} else {
log = new Brolog()
if (level) {
log.warn('Brolog', 'env WECHATY_LOG(%s) must be one of silly|verbose|info|warn|error|silent', level)
}
} else if (level) {
log.warn('Brolog', 'env WECHATY_LOG(%s) must be one of silly|verbose|info|warn|error|silent', level)
}
export { Brolog }
export default Brolog
export { log }
export default log
......@@ -16,11 +16,13 @@
*/
// import Brolog from 'brolog'
import { Config } from './config'
import {
Config,
log as globalLog,
} from './config'
import { Io } from './io'
import { StateMonitor } from './state-monitor'
import { Wechaty } from './wechaty'
import { Brolog } from './brolog-env'
export class IoClient {
......@@ -31,7 +33,7 @@ export class IoClient {
constructor(
private token: string = Config.token || Config.DEFAULT_TOKEN,
private log: any = new Brolog(),
private log: any = globalLog,
) {
if (!log) {
const e = new Error('constructor() log(npmlog/brolog) must be set')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册