cgserver 11.2.1 → 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.
package/README.md
CHANGED
|
@@ -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",
|
|
@@ -143,23 +139,15 @@ class FrameworkConfig extends Config_1.Config {
|
|
|
143
139
|
},
|
|
144
140
|
categories: {
|
|
145
141
|
default: {
|
|
146
|
-
appenders: ['log_file'],
|
|
147
|
-
level: 'ALL'
|
|
148
|
-
},
|
|
149
|
-
console: {
|
|
150
|
-
appenders: ['console'],
|
|
151
|
-
level: 'ALL'
|
|
152
|
-
},
|
|
153
|
-
logger: {
|
|
154
|
-
appenders: ['log_file'],
|
|
142
|
+
appenders: ['log_file', 'console'],
|
|
155
143
|
level: 'ALL'
|
|
156
144
|
},
|
|
157
145
|
client_logger: {
|
|
158
|
-
appenders: ['client_log_file'],
|
|
146
|
+
appenders: ['client_log_file', 'console'],
|
|
159
147
|
level: 'ALL'
|
|
160
148
|
},
|
|
161
149
|
error_logger: {
|
|
162
|
-
appenders: ['error_log_file'],
|
|
150
|
+
appenders: ['error_log_file', 'console'],
|
|
163
151
|
level: 'ALL'
|
|
164
152
|
}
|
|
165
153
|
}
|
|
@@ -178,7 +166,7 @@ class FrameworkConfig extends Config_1.Config {
|
|
|
178
166
|
}
|
|
179
167
|
init() {
|
|
180
168
|
let ret = super.init();
|
|
181
|
-
Log_1.gLog.init(this.log
|
|
169
|
+
Log_1.gLog.init(this.log);
|
|
182
170
|
return ret;
|
|
183
171
|
}
|
|
184
172
|
}
|
|
@@ -26,25 +26,17 @@ 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
|
}
|
|
43
37
|
colors.enable();
|
|
44
38
|
log4js.configure(cfg);
|
|
45
|
-
|
|
46
|
-
this._logger = log4js.getLogger("logger");
|
|
47
|
-
}
|
|
39
|
+
this._logger = log4js.getLogger();
|
|
48
40
|
if (cfg.categories.client_logger) {
|
|
49
41
|
this._client_logger = log4js.getLogger("client_logger");
|
|
50
42
|
}
|
|
@@ -66,26 +58,14 @@ class Log {
|
|
|
66
58
|
error(message) {
|
|
67
59
|
message = this._convertMsg(message);
|
|
68
60
|
this._error_logger?.error(message);
|
|
69
|
-
if (this._console_level >= 0) {
|
|
70
|
-
let time_str = this._getTimeStr();
|
|
71
|
-
console.error(time_str + " " + message);
|
|
72
|
-
}
|
|
73
61
|
}
|
|
74
62
|
info(message) {
|
|
75
63
|
message = this._convertMsg(message);
|
|
76
64
|
this._logger?.info(message);
|
|
77
|
-
if (this._console_level >= 0) {
|
|
78
|
-
let time_str = this._getTimeStr();
|
|
79
|
-
console.log(time_str + " " + message);
|
|
80
|
-
}
|
|
81
65
|
}
|
|
82
66
|
warn(message) {
|
|
83
67
|
message = this._convertMsg(message);
|
|
84
68
|
this._error_logger?.warn(message);
|
|
85
|
-
if (this._console_level >= 0) {
|
|
86
|
-
let time_str = this._getTimeStr();
|
|
87
|
-
console.warn(time_str + " " + message);
|
|
88
|
-
}
|
|
89
69
|
}
|
|
90
70
|
record(message) {
|
|
91
71
|
this.info(message);
|
|
@@ -94,12 +74,6 @@ class Log {
|
|
|
94
74
|
message = this._convertMsg(message);
|
|
95
75
|
this._client_logger?.info(message);
|
|
96
76
|
}
|
|
97
|
-
_getTimeStr() {
|
|
98
|
-
let time = new Date();
|
|
99
|
-
let time_str = this._format(time, "[YYYY-MM-DD HH:mm:SS.");
|
|
100
|
-
time_str += time.getMilliseconds() + "]";
|
|
101
|
-
return time_str;
|
|
102
|
-
}
|
|
103
77
|
_isObject(param) {
|
|
104
78
|
return typeof (param) === "object";
|
|
105
79
|
}
|
|
@@ -109,42 +83,6 @@ class Log {
|
|
|
109
83
|
_isNumber(param) {
|
|
110
84
|
return typeof (param) === "number";
|
|
111
85
|
}
|
|
112
|
-
_format(src, formatStr) {
|
|
113
|
-
if (this._isString(src)) {
|
|
114
|
-
let args = Array.prototype.slice.call(arguments, 1);
|
|
115
|
-
return src.replace(/\{(\d+)\}/g, function (m, i) {
|
|
116
|
-
return args[i];
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
if (this._isNumber(src)) {
|
|
121
|
-
src = new Date(src);
|
|
122
|
-
}
|
|
123
|
-
let str = formatStr;
|
|
124
|
-
let Week = ['日', '一', '二', '三', '四', '五', '六'];
|
|
125
|
-
let month = src.getMonth() + 1;
|
|
126
|
-
let year = src.getFullYear();
|
|
127
|
-
let date = src.getDate();
|
|
128
|
-
let hour = src.getHours();
|
|
129
|
-
let min = src.getMinutes();
|
|
130
|
-
let sec = src.getSeconds();
|
|
131
|
-
let day = src.getDay();
|
|
132
|
-
str = str.replace(/yyyy|YYYY/, year);
|
|
133
|
-
str = str.replace(/yy|YY/, (year % 100) > 9 ? (year % 100).toString() : '0' + (year % 100));
|
|
134
|
-
str = str.replace(/MM/, month > 9 ? month.toString() : '0' + month);
|
|
135
|
-
str = str.replace(/M/g, month);
|
|
136
|
-
str = str.replace(/w|W/g, Week[day]);
|
|
137
|
-
str = str.replace(/dd|DD/, date > 9 ? date.toString() : '0' + date);
|
|
138
|
-
str = str.replace(/d|D/g, date);
|
|
139
|
-
str = str.replace(/hh|HH/, hour > 9 ? hour.toString() : '0' + hour);
|
|
140
|
-
str = str.replace(/h|H/g, hour);
|
|
141
|
-
str = str.replace(/mm/, min > 9 ? min.toString() : '0' + min);
|
|
142
|
-
str = str.replace(/m/g, min);
|
|
143
|
-
str = str.replace(/ss|SS/, sec > 9 ? sec.toString() : '0' + sec);
|
|
144
|
-
str = str.replace(/s|S/g, sec);
|
|
145
|
-
return str;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
86
|
}
|
|
149
87
|
exports.Log = Log;
|
|
150
88
|
exports.gLog = new Log();
|
|
@@ -102,7 +102,6 @@ declare class AlipayConfig {
|
|
|
102
102
|
notify_url_dev: "";
|
|
103
103
|
}
|
|
104
104
|
export declare class FrameworkConfig extends Config {
|
|
105
|
-
console_level: number;
|
|
106
105
|
log: {
|
|
107
106
|
appenders: {
|
|
108
107
|
console: {
|
|
@@ -152,14 +151,6 @@ export declare class FrameworkConfig extends Config {
|
|
|
152
151
|
appenders: string[];
|
|
153
152
|
level: string;
|
|
154
153
|
};
|
|
155
|
-
console: {
|
|
156
|
-
appenders: string[];
|
|
157
|
-
level: string;
|
|
158
|
-
};
|
|
159
|
-
logger: {
|
|
160
|
-
appenders: string[];
|
|
161
|
-
level: string;
|
|
162
|
-
};
|
|
163
154
|
client_logger: {
|
|
164
155
|
appenders: string[];
|
|
165
156
|
level: string;
|
|
@@ -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;
|