egg-json-logger-wrapper
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -40,3 +40,3 @@ 'use strict'; | ||
origin: ctx.origin, | ||
ip: ctx.ip, | ||
ip: ctx['mx_ip'] || ctx.ip, | ||
host: ctx.host, | ||
@@ -63,3 +63,3 @@ method: ctx.method, | ||
origin: ctx.origin, | ||
ip: ctx.ip, | ||
ip: ctx['mx_ip'] || ctx.ip, | ||
host: ctx.host, | ||
@@ -85,3 +85,3 @@ method: ctx.method, | ||
origin: ctx.origin, | ||
ip: ctx.ip, | ||
ip: ctx['mx_ip'] || ctx.ip, | ||
host: ctx.host, | ||
@@ -88,0 +88,0 @@ method: ctx.method, |
@@ -9,4 +9,10 @@ 'use strict'; | ||
this[REQID] = this["mx_trace_id"] || uuidv4() | ||
this['mx_trace_id'] = this[REQID]; | ||
this.mx_ip = this.headers['x-real-ip'] || this.request.ip; | ||
return { | ||
trace_id: this[REQID], | ||
mx_ip: this.mx_ip, | ||
mx_trace_id: this['mx_trace_id'], | ||
user_id: this?.userInfo?.userId || 'anonymous', | ||
@@ -13,0 +19,0 @@ duration: this.starttime ? Date.now() - this.starttime : 0 |
@@ -21,3 +21,3 @@ 'use strict'; | ||
let obj = JSON.parse(msg) | ||
if (!obj.hasOwnProperty('trace_id') && !obj.hasOwnProperty('error')) { | ||
if (!obj.hasOwnProperty('mx_trace_id') && !obj.hasOwnProperty('error')) { | ||
obj = {[`log${index++}`]: obj} | ||
@@ -24,0 +24,0 @@ } |
{ | ||
"name": "egg-json-logger-wrapper", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "JSON 化输出logger, 使用 阿里云日志服务 => LogStore => 采集日志 => 文本格式日志 => JSON模式", | ||
@@ -5,0 +5,0 @@ "eggPlugin": { |
16207
240