badmfck-api-server 1.4.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,7 @@ async function Initializer(services) {
43
43
  exports.Initializer = Initializer;
44
44
  class APIService extends BaseService_1.BaseService {
45
45
  static nextLogID = 0;
46
- version = "1.4.1";
46
+ version = "1.4.3";
47
47
  options;
48
48
  netLog = [];
49
49
  constructor(options) {
@@ -13,10 +13,12 @@ export interface ILogItem {
13
13
  time: number;
14
14
  text: string;
15
15
  date: string;
16
+ source: string;
16
17
  }
17
18
  export interface ILogServiceOptions {
18
19
  output?: (data?: any) => void;
19
20
  stackSize: number;
21
+ level: LOG_LEVEL;
20
22
  }
21
23
  export declare const getDefaultLogOptions: () => ILogServiceOptions;
22
24
  export declare const logInfo: (message: any, ...optional: any[]) => void;
@@ -36,7 +36,8 @@ var LOG_LEVEL;
36
36
  })(LOG_LEVEL || (exports.LOG_LEVEL = LOG_LEVEL = {}));
37
37
  const getDefaultLogOptions = () => {
38
38
  return {
39
- stackSize: 1000
39
+ stackSize: 1000,
40
+ level: LOG_LEVEL.ALL
40
41
  };
41
42
  };
42
43
  exports.getDefaultLogOptions = getDefaultLogOptions;
@@ -63,6 +64,7 @@ class LogService extends BaseService_1.BaseService {
63
64
  if (!opt)
64
65
  opt = (0, exports.getDefaultLogOptions)();
65
66
  this.options = opt;
67
+ this.level = opt.level;
66
68
  }
67
69
  async init() {
68
70
  exports.REQ_LOG.listener = async (req) => {
@@ -81,9 +83,14 @@ class LogService extends BaseService_1.BaseService {
81
83
  const msg = log.data[0];
82
84
  const optional = log.data[1];
83
85
  let text = this.createText(msg);
86
+ let source = "";
87
+ if (text.startsWith("${") && text.endsWith("}") && text.indexOf(".js") !== -1) {
88
+ source = text.substring(2, text.length - 1);
89
+ text = "";
90
+ }
84
91
  if (optional) {
85
92
  for (let i of optional)
86
- text += ", " + this.createText(optional);
93
+ text += ", " + this.createText(i);
87
94
  }
88
95
  const d = new Date();
89
96
  const logitem = {
@@ -91,10 +98,11 @@ class LogService extends BaseService_1.BaseService {
91
98
  id: ((+new Date()) - this.epoch),
92
99
  text: text,
93
100
  time: d.getTime(),
94
- date: this.createDate(d)
101
+ date: this.createDate(d),
102
+ source: source
95
103
  };
96
104
  if (this.options.output)
97
- this.options.output(logitem.level + " > " + logitem.date + " > " + text);
105
+ this.options.output(logitem.source + " > " + logitem.level + " > " + logitem.date + " > " + text);
98
106
  exports.S_LOG_CREATED.invoke(logitem);
99
107
  this.log.push(logitem);
100
108
  let limit = this.options.stackSize ?? 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",