cgserver 11.2.2 → 11.2.3
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.
|
@@ -93,15 +93,11 @@ class AlipayConfig {
|
|
|
93
93
|
notify_url_dev;
|
|
94
94
|
}
|
|
95
95
|
class FrameworkConfig extends Config_1.Config {
|
|
96
|
-
/*
|
|
97
|
-
*-1不输出到console,0,仅错误信息输出到console,1,都输出到console
|
|
98
|
-
*/
|
|
99
|
-
console_level = 0;
|
|
100
96
|
log = {
|
|
101
97
|
appenders: {
|
|
102
98
|
console: {
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
type: "console",
|
|
100
|
+
category: "console"
|
|
105
101
|
},
|
|
106
102
|
log_file: {
|
|
107
103
|
category: "log_file",
|
|
@@ -170,7 +166,7 @@ class FrameworkConfig extends Config_1.Config {
|
|
|
170
166
|
}
|
|
171
167
|
init() {
|
|
172
168
|
let ret = super.init();
|
|
173
|
-
Log_1.gLog.init(this.log
|
|
169
|
+
Log_1.gLog.init(this.log);
|
|
174
170
|
return ret;
|
|
175
171
|
}
|
|
176
172
|
}
|
|
@@ -26,17 +26,11 @@ class Log {
|
|
|
26
26
|
//error and warn
|
|
27
27
|
_error_logger = null;
|
|
28
28
|
_inited = false;
|
|
29
|
-
|
|
30
|
-
* 该level只是用来控制控制台的显示的
|
|
31
|
-
* -1不输出到console,0,仅错误信息输出到console,1,都输出到console
|
|
32
|
-
*/
|
|
33
|
-
_console_level = 0;
|
|
34
|
-
init(cfg, console_level = 0) {
|
|
29
|
+
init(cfg) {
|
|
35
30
|
if (this._inited) {
|
|
36
31
|
return;
|
|
37
32
|
}
|
|
38
33
|
this._inited = true;
|
|
39
|
-
this._console_level = console_level;
|
|
40
34
|
if (!cfg) {
|
|
41
35
|
return;
|
|
42
36
|
}
|
|
@@ -64,26 +58,14 @@ class Log {
|
|
|
64
58
|
error(message) {
|
|
65
59
|
message = this._convertMsg(message);
|
|
66
60
|
this._error_logger?.error(message);
|
|
67
|
-
if (this._console_level >= 0) {
|
|
68
|
-
let time_str = this._getTimeStr();
|
|
69
|
-
console.error(time_str + " " + message);
|
|
70
|
-
}
|
|
71
61
|
}
|
|
72
62
|
info(message) {
|
|
73
63
|
message = this._convertMsg(message);
|
|
74
64
|
this._logger?.info(message);
|
|
75
|
-
if (this._console_level >= 0) {
|
|
76
|
-
let time_str = this._getTimeStr();
|
|
77
|
-
console.log(time_str + " " + message);
|
|
78
|
-
}
|
|
79
65
|
}
|
|
80
66
|
warn(message) {
|
|
81
67
|
message = this._convertMsg(message);
|
|
82
68
|
this._error_logger?.warn(message);
|
|
83
|
-
if (this._console_level >= 0) {
|
|
84
|
-
let time_str = this._getTimeStr();
|
|
85
|
-
console.warn(time_str + " " + message);
|
|
86
|
-
}
|
|
87
69
|
}
|
|
88
70
|
record(message) {
|
|
89
71
|
this.info(message);
|
|
@@ -92,12 +74,6 @@ class Log {
|
|
|
92
74
|
message = this._convertMsg(message);
|
|
93
75
|
this._client_logger?.info(message);
|
|
94
76
|
}
|
|
95
|
-
_getTimeStr() {
|
|
96
|
-
let time = new Date();
|
|
97
|
-
let time_str = this._format(time, "[YYYY-MM-DD HH:mm:SS.");
|
|
98
|
-
time_str += time.getMilliseconds() + "]";
|
|
99
|
-
return time_str;
|
|
100
|
-
}
|
|
101
77
|
_isObject(param) {
|
|
102
78
|
return typeof (param) === "object";
|
|
103
79
|
}
|
|
@@ -107,42 +83,6 @@ class Log {
|
|
|
107
83
|
_isNumber(param) {
|
|
108
84
|
return typeof (param) === "number";
|
|
109
85
|
}
|
|
110
|
-
_format(src, formatStr) {
|
|
111
|
-
if (this._isString(src)) {
|
|
112
|
-
let args = Array.prototype.slice.call(arguments, 1);
|
|
113
|
-
return src.replace(/\{(\d+)\}/g, function (m, i) {
|
|
114
|
-
return args[i];
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
if (this._isNumber(src)) {
|
|
119
|
-
src = new Date(src);
|
|
120
|
-
}
|
|
121
|
-
let str = formatStr;
|
|
122
|
-
let Week = ['日', '一', '二', '三', '四', '五', '六'];
|
|
123
|
-
let month = src.getMonth() + 1;
|
|
124
|
-
let year = src.getFullYear();
|
|
125
|
-
let date = src.getDate();
|
|
126
|
-
let hour = src.getHours();
|
|
127
|
-
let min = src.getMinutes();
|
|
128
|
-
let sec = src.getSeconds();
|
|
129
|
-
let day = src.getDay();
|
|
130
|
-
str = str.replace(/yyyy|YYYY/, year);
|
|
131
|
-
str = str.replace(/yy|YY/, (year % 100) > 9 ? (year % 100).toString() : '0' + (year % 100));
|
|
132
|
-
str = str.replace(/MM/, month > 9 ? month.toString() : '0' + month);
|
|
133
|
-
str = str.replace(/M/g, month);
|
|
134
|
-
str = str.replace(/w|W/g, Week[day]);
|
|
135
|
-
str = str.replace(/dd|DD/, date > 9 ? date.toString() : '0' + date);
|
|
136
|
-
str = str.replace(/d|D/g, date);
|
|
137
|
-
str = str.replace(/hh|HH/, hour > 9 ? hour.toString() : '0' + hour);
|
|
138
|
-
str = str.replace(/h|H/g, hour);
|
|
139
|
-
str = str.replace(/mm/, min > 9 ? min.toString() : '0' + min);
|
|
140
|
-
str = str.replace(/m/g, min);
|
|
141
|
-
str = str.replace(/ss|SS/, sec > 9 ? sec.toString() : '0' + sec);
|
|
142
|
-
str = str.replace(/s|S/g, sec);
|
|
143
|
-
return str;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
86
|
}
|
|
147
87
|
exports.Log = Log;
|
|
148
88
|
exports.gLog = new Log();
|
|
@@ -4,22 +4,15 @@ export declare class Log {
|
|
|
4
4
|
protected _client_logger: log4js.Logger;
|
|
5
5
|
protected _error_logger: log4js.Logger;
|
|
6
6
|
protected _inited: boolean;
|
|
7
|
-
|
|
8
|
-
* 该level只是用来控制控制台的显示的
|
|
9
|
-
* -1不输出到console,0,仅错误信息输出到console,1,都输出到console
|
|
10
|
-
*/
|
|
11
|
-
protected _console_level: number;
|
|
12
|
-
init(cfg?: log4js.Configuration, console_level?: number): void;
|
|
7
|
+
init(cfg?: log4js.Configuration): void;
|
|
13
8
|
protected _convertMsg(message?: any): any;
|
|
14
9
|
error(message?: any): void;
|
|
15
10
|
info(message: any): void;
|
|
16
11
|
warn(message?: any): void;
|
|
17
12
|
record(message?: any): void;
|
|
18
13
|
clientLog(message?: any): void;
|
|
19
|
-
protected _getTimeStr(): any;
|
|
20
14
|
protected _isObject(param: any): boolean;
|
|
21
15
|
protected _isString(param: any): boolean;
|
|
22
16
|
protected _isNumber(param: any): boolean;
|
|
23
|
-
protected _format(src: any, formatStr: any): any;
|
|
24
17
|
}
|
|
25
18
|
export declare let gLog: Log;
|