This commit is contained in:
idranme 2024-08-28 17:13:26 +08:00
parent 8564630c4d
commit 183eab2cf4
No known key found for this signature in database
GPG Key ID: 926F7B5B668E495F
3 changed files with 5 additions and 8 deletions

View File

@ -18,18 +18,15 @@ export default class Log {
return return
} }
const file = path.join(LOG_DIR, cfg.filename) const file = path.join(LOG_DIR, cfg.filename)
const refreshNick = ctx.debounce(() => { /*const refreshNick = ctx.debounce(() => {
const ntUserApi = ctx.get('ntUserApi') const ntUserApi = ctx.get('ntUserApi')
if (ntUserApi && !selfInfo.nick) { if (ntUserApi && !selfInfo.nick) {
ntUserApi.getSelfNick(true) ntUserApi.getSelfNick(true)
} }
}, 1000) }, 1000)*/
const target: Logger.Target = { const target: Logger.Target = {
colors: 0, colors: 0,
record: (record: Logger.Record) => { record: (record: Logger.Record) => {
if (!selfInfo.nick) {
refreshNick()
}
const dateTime = new Date(record.timestamp).toLocaleString() const dateTime = new Date(record.timestamp).toLocaleString()
const userInfo = selfInfo.uin ? `${selfInfo.nick}(${selfInfo.uin})` : '' const userInfo = selfInfo.uin ? `${selfInfo.nick}(${selfInfo.uin})` : ''
const content = `${dateTime} [${record.type}] ${userInfo} | ${record.name} ${record.content}\n\n` const content = `${dateTime} [${record.type}] ${userInfo} | ${record.name} ${record.content}\n\n`

View File

@ -153,8 +153,8 @@ export function invoke<ReturnType>(params: InvokeParams<ReturnType>) {
afterFirstCmd && secondCallback() afterFirstCmd && secondCallback()
} }
else { else {
log('ntqq api call failed', result) log('ntqq api call failed,', params.methodName, result)
reject(`ntqq api call failed, ${result.errMsg}`) reject(`ntqq api call failed, ${params.methodName}, ${result.errMsg}`)
} }
} }
} }

View File

@ -261,7 +261,7 @@ class OB11WebSocketReverse {
this.wsClient.on('close', () => { this.wsClient.on('close', () => {
disposeHeartBeat() disposeHeartBeat()
this.ctx.logger.info('The websocket connection: ' + this.config.url + ' closed, trying reconnecting...') this.ctx.logger.info(`The websocket connection: ${this.config.url} closed${this.running ? ', trying reconnecting...' : ''}`)
if (this.running) { if (this.running) {
this.ctx.setTimeout(() => this.tryConnect(), 3000) this.ctx.setTimeout(() => this.tryConnect(), 3000)
} }