@oino-ts/common 0.21.2 → 1.0.0

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.
Files changed (69) hide show
  1. package/README.md +183 -0
  2. package/dist/cjs/OINOApi.js +322 -0
  3. package/dist/cjs/OINOConfig.js +104 -0
  4. package/dist/cjs/OINOConstants.js +42 -0
  5. package/dist/cjs/OINODataField.js +346 -0
  6. package/dist/cjs/OINODataModel.js +182 -0
  7. package/dist/cjs/OINODataSource.js +165 -0
  8. package/dist/cjs/OINOFormatter.js +6 -5
  9. package/dist/cjs/OINOHtmlTemplate.js +21 -18
  10. package/dist/cjs/OINOModelSet.js +333 -0
  11. package/dist/cjs/OINOParser.js +448 -0
  12. package/dist/cjs/OINOQueryParams.js +434 -0
  13. package/dist/cjs/OINORequest.js +21 -13
  14. package/dist/cjs/OINOResult.js +13 -12
  15. package/dist/cjs/OINOStr.js +11 -11
  16. package/dist/cjs/OINOSwagger.js +205 -0
  17. package/dist/cjs/index.js +57 -39
  18. package/dist/esm/OINOApi.js +315 -0
  19. package/dist/esm/OINOConfig.js +100 -0
  20. package/dist/esm/OINOConstants.js +39 -0
  21. package/dist/esm/OINODataField.js +337 -0
  22. package/dist/esm/OINODataModel.js +178 -0
  23. package/dist/esm/OINODataSource.js +159 -0
  24. package/dist/esm/OINOFormatter.js +2 -1
  25. package/dist/esm/OINOHtmlTemplate.js +4 -1
  26. package/dist/esm/OINOModelSet.js +329 -0
  27. package/dist/esm/OINOParser.js +444 -0
  28. package/dist/esm/OINOQueryParams.js +426 -0
  29. package/dist/esm/OINORequest.js +9 -1
  30. package/dist/esm/OINOResult.js +2 -1
  31. package/dist/esm/OINOStr.js +1 -1
  32. package/dist/esm/OINOSwagger.js +201 -0
  33. package/dist/esm/index.js +14 -32
  34. package/dist/types/OINOApi.d.ts +191 -0
  35. package/dist/types/OINOConfig.d.ts +63 -0
  36. package/dist/types/OINOConstants.d.ts +51 -0
  37. package/dist/types/OINODataField.d.ts +209 -0
  38. package/dist/types/OINODataModel.d.ts +78 -0
  39. package/dist/types/OINODataSource.d.ts +184 -0
  40. package/dist/types/OINOHtmlTemplate.d.ts +1 -1
  41. package/dist/types/OINOModelSet.d.ts +64 -0
  42. package/dist/types/OINOParser.d.ts +42 -0
  43. package/dist/types/OINOQueryParams.d.ts +270 -0
  44. package/dist/types/OINORequest.d.ts +4 -1
  45. package/dist/types/OINOResult.d.ts +1 -1
  46. package/dist/types/OINOStr.d.ts +1 -1
  47. package/dist/types/OINOSwagger.d.ts +25 -0
  48. package/dist/types/index.d.ts +14 -31
  49. package/package.json +32 -32
  50. package/src/OINOApi.ts +429 -0
  51. package/src/OINOBenchmark.ts +323 -323
  52. package/src/OINOConfig.ts +113 -0
  53. package/src/OINOConstants.ts +59 -0
  54. package/src/OINODataField.ts +371 -0
  55. package/src/OINODataModel.ts +187 -0
  56. package/src/OINODataSource.ts +280 -0
  57. package/src/OINOFormatter.ts +166 -165
  58. package/src/OINOHeaders.ts +51 -51
  59. package/src/OINOHtmlTemplate.test.ts +114 -114
  60. package/src/OINOHtmlTemplate.ts +225 -222
  61. package/src/OINOLog.ts +292 -292
  62. package/src/OINOModelSet.ts +359 -0
  63. package/src/OINOParser.ts +441 -0
  64. package/src/OINOQueryParams.ts +449 -0
  65. package/src/OINORequest.ts +204 -196
  66. package/src/OINOResult.ts +331 -330
  67. package/src/OINOStr.ts +254 -254
  68. package/src/OINOSwagger.ts +213 -0
  69. package/src/index.ts +18 -38
package/src/OINOLog.ts CHANGED
@@ -1,292 +1,292 @@
1
- /*
2
- * This Source Code Form is subject to the terms of the Mozilla Public
3
- * License, v. 2.0. If a copy of the MPL was not distributed with this
4
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
- */
6
-
7
- import { OINOBenchmark } from "./OINOBenchmark"
8
-
9
- /** Logging levels */
10
- export enum OINOLogLevel {
11
- /** Debug messages */
12
- debug=1,
13
- /** Informational messages */
14
- info=2,
15
- /** Warning messages */
16
- warning=3,
17
- /** Error messages */
18
- error=4,
19
- /** Exception messages */
20
- exception=5
21
- }
22
-
23
- /**
24
- * Abstract base class for logging implementations supporting
25
- * - error, warning, info and debug channels
26
- * - setting level of logs outputted
27
- *
28
- */
29
-
30
- export abstract class OINOLog {
31
- protected static _instance:OINOLog
32
-
33
- protected _logLevels:Record<string, OINOLogLevel> = { "|||": OINOLogLevel.warning }
34
- protected _defaultLogLevel:OINOLogLevel = OINOLogLevel.warning
35
-
36
- /**
37
- * Abstract logging method to implement the actual logging operation.
38
- *
39
- * @param logLevel default loglevel for all log events
40
- *
41
- */
42
- constructor (logLevel:OINOLogLevel = OINOLogLevel.warning) {
43
- // console.log("OINOLog.constructor: logLevel=" + logLevel)
44
- this._logLevels["|||"] = logLevel
45
- this._defaultLogLevel = logLevel
46
- }
47
-
48
-
49
- /**
50
- * Abstract logging method to implement the actual logging operation.
51
- *
52
- * @param levelStr level string of the log event
53
- * @param domain domain of the log event
54
- * @param channel channel of the log event
55
- * @param method method of the log event
56
- * @param message message of the log event
57
- * @param data structured data associated with the log event
58
- *
59
- */
60
- protected abstract _writeLog(levelStr:string, domain:string, channel:string, method:string, message:string, data?:any):void
61
-
62
- /**
63
- * Abstract logging method to implement the actual logging operation.
64
- *
65
- * @param level level of the log event
66
- * @param levelStr level string of the log event
67
- * @param message message of the log event
68
- * @param data structured data associated with the log event
69
- *
70
- */
71
- protected static _log(level:OINOLogLevel, levelStr:string, domain:string, channel:string, method:string, message:string, data?:any):void {
72
- if (OINOLog._instance) {
73
- const log_levels = OINOLog._instance._logLevels
74
- // console.log(log_levels)
75
- const min_level =
76
- log_levels[domain + "|" + channel + "|" + method + "|" + message] ||
77
- log_levels[domain + "|" + channel + "|" + method + "|"] ||
78
- log_levels[domain + "|" + channel + "||"] ||
79
- log_levels[domain + "|||"] ||
80
- log_levels["|||"]
81
- // console.log("_log: level=" + level + ", min_level=" + min_level + ", levelStr=" + levelStr + ", message=" + message, data)
82
- if (level >= min_level) {
83
- OINOLog._instance?._writeLog(levelStr, domain, channel, method, message, data)
84
- }
85
- }
86
- }
87
-
88
- /**
89
- * Set active logger instance.
90
- *
91
- * @param instance OINOLog instance
92
- *
93
- */
94
- static setInstance(instance: OINOLog) {
95
- // console.log("setLogger: " + log)
96
- if (instance) {
97
- OINOLog._instance = instance
98
- }
99
- }
100
-
101
- /**
102
- * Set log level for given combination of domain/channel/method. Not defining dimension(s) means they match any value.
103
- * Multiple settings can be combined to set different logging accuracy specifically
104
- *
105
- * For example:
106
- * logLevel: warning, domain: "", channel: "", method: "" will only output warning and higher events.
107
- * logLevel: debug, domain: d1, channel: c1, method: "" will enable debug events for channel c1 of domain d1.
108
- * logLevel: info, domain: d1, channel: c1, method: m1 will supress debug events for method m1.
109
- *
110
- * @param logLevel log level to use
111
- * @param domain domain of the log event (default: "" for all)
112
- * @param channel channel of the log event (default: "" for all)
113
- * @param method method of the log event (default: "" for all)
114
- * @param message message of the log event (default: "" for all)
115
- */
116
- static setLogLevel(logLevel:OINOLogLevel, domain:string = "", channel:string = "", method:string = "", message:string = "") {
117
- if (OINOLog._instance) {
118
- OINOLog._instance._logLevels[domain + "|" + channel + "|" + method + "|" + message] = logLevel
119
- }
120
- }
121
-
122
- /**
123
- * Log exception event. Exception events are prettyprinted and preserve newlines so that stack traces are readable.
124
- *
125
- * @param domain domain of the log event
126
- * @param channel channel of the log event
127
- * @param method method of the log event
128
- * @param message message of the log event
129
- * @param data structured data associated with the log event
130
- *
131
- */
132
- static exception(domain:string, channel:string, method:string, message:string, data?:any) {
133
- OINOLog._log(OINOLogLevel.exception, "EXCEPTION", domain, channel, method, message, data)
134
- OINOBenchmark.trackException(domain + "." + channel, method, message, data?.message || "", data?.stack || "")
135
- }
136
-
137
- /**
138
- * Log error event. Error events are printed as a single line.
139
- *
140
- * @param domain domain of the log event
141
- * @param channel channel of the log event
142
- * @param method method of the log event
143
- * @param message message of the log event
144
- * @param data structured data associated with the log event
145
- *
146
- */
147
- static error(domain:string, channel:string, method:string, message:string, data?:any) {
148
- OINOLog._log(OINOLogLevel.error, "ERROR", domain, channel, method, message, data)
149
- }
150
-
151
- /**
152
- * Log warning event. Warning events are printed as a single line.
153
- *
154
- * @param domain domain of the log event
155
- * @param channel channel of the log event
156
- * @param method method of the log event
157
- * @param message message of the log event
158
- * @param data structured data associated with the log event
159
- *
160
- */
161
- static warning(domain:string, channel:string, method:string, message:string, data?:any) {
162
- OINOLog._log(OINOLogLevel.warning, "WARN", domain, channel, method, message, data)
163
- }
164
-
165
- /**
166
- * Log info event. Info events are printed as a single line.
167
- *
168
- * @param domain domain of the log event
169
- * @param channel channel of the log event
170
- * @param method method of the log event
171
- * @param message message of the log event
172
- * @param data structured data associated with the log event
173
- *
174
- */
175
- static info(domain:string, channel:string, method:string, message:string, data?:any) {
176
- OINOLog._log(OINOLogLevel.info, "INFO", domain, channel, method, message, data)
177
- }
178
-
179
- /**
180
- * Log debug event. Debug events are prettyprinted.
181
- *
182
- * @param domain domain of the log event
183
- * @param channel channel of the log event
184
- * @param method method of the log event
185
- * @param message message of the log event
186
- * @param data structured data associated with the log event
187
- *
188
- */
189
- static debug(domain:string, channel:string, method:string, message:string, data?:any) {
190
- OINOLog._log(OINOLogLevel.debug, "DEBUG", domain, channel, method, message, data)
191
- }
192
-
193
- /**
194
- * Get current log levels as an array of objects with domain, channel, method and level.
195
- *
196
- */
197
- static exportLogLevels():any[] {
198
- let result:any = []
199
- if (OINOLog._instance) {
200
- for (const key in OINOLog._instance._logLevels) {
201
- const level = OINOLog._instance._logLevels[key]
202
- if (level) {
203
- const parts = key.split("|")
204
- result.push({
205
- domain: parts[0] || "",
206
- channel: parts[1] || "",
207
- method: parts[2] || "",
208
- message: parts[3] || "",
209
- level: level
210
- })
211
- }
212
- }
213
- }
214
- return result
215
- }
216
-
217
-
218
- /**
219
- * Set log levels from an array of objects with domain, channel, method and level overwriting existing values (i.e. non-existing values are not affected).
220
- *
221
- * @param logLevels array of log level objects
222
- *
223
- */
224
- static setLogLevels(logLevels:any[]):void {
225
- if (OINOLog._instance) {
226
- for (const logLevel of logLevels) {
227
- const domain = logLevel.domain || ""
228
- const channel = logLevel.channel || ""
229
- const method = logLevel.method || ""
230
- const message = logLevel.message || ""
231
- const level = logLevel.level
232
- if (level && OINOLogLevel[level]) {
233
- OINOLog._instance._logLevels[domain + "|" + channel + "|" + method + "|" + message] = level
234
- }
235
- }
236
- }
237
- }
238
-
239
- /**
240
- * Import log levels from an array of objects with domain, channel, method and level resetting existing values (i.e. non-existing values get removed).
241
- *
242
- * @param logLevels array of log level objects
243
- *
244
- */
245
- static importLogLevels(logLevels:any[]):void {
246
- if (OINOLog._instance) {
247
- OINOLog._instance._logLevels = {"|||": OINOLog._instance._defaultLogLevel} // reset to default log level
248
- this.setLogLevels(logLevels)
249
- }
250
- }
251
- }
252
-
253
- /**
254
- * Logging implementation based on console.log.
255
- *
256
- */
257
- export class OINOConsoleLog extends OINOLog {
258
-
259
- /**
260
- * Constructor of `OINOConsoleLog`
261
- * @param logLevel logging level
262
- */
263
- constructor (logLevel:OINOLogLevel = OINOLogLevel.warning) {
264
- super(logLevel)
265
- }
266
-
267
- protected _writeLog(level:string, domain:string, channel:string, method:string, message:string, data?:any):void {
268
- if (message === undefined) {
269
- console.log("OINOLog missing message: " + (new Error()).stack)
270
- }
271
- let log:string = "OINOLog." + level + " | " + domain + " | " + channel + " | " + method + ": " + message
272
- let logger_func
273
- if ((level == "ERROR") || (level == "EXCEPTION")) {
274
- logger_func = console.error
275
- } else if (level == "WARN") {
276
- logger_func = console.warn
277
- } else if (level == "INFO") {
278
- logger_func = console.info
279
- } else {
280
- logger_func = console.log
281
- }
282
- if (data && (level == "DEBUG")) {
283
- logger_func(log, data)
284
- } else if (data && (level == "EXCEPTION")) {
285
- logger_func(log + JSON.stringify(data, null, 2).replaceAll(/[^\\]\\n/g, "\n")) // preserve newlines for stack traces
286
- } else if (data) {
287
- logger_func(log + " " + JSON.stringify(data))
288
- } else {
289
- logger_func(log)
290
- }
291
- }
292
- }
1
+ /*
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+
7
+ import { OINOBenchmark } from "./OINOBenchmark"
8
+
9
+ /** Logging levels */
10
+ export enum OINOLogLevel {
11
+ /** Debug messages */
12
+ debug=1,
13
+ /** Informational messages */
14
+ info=2,
15
+ /** Warning messages */
16
+ warning=3,
17
+ /** Error messages */
18
+ error=4,
19
+ /** Exception messages */
20
+ exception=5
21
+ }
22
+
23
+ /**
24
+ * Abstract base class for logging implementations supporting
25
+ * - error, warning, info and debug channels
26
+ * - setting level of logs outputted
27
+ *
28
+ */
29
+
30
+ export abstract class OINOLog {
31
+ protected static _instance:OINOLog
32
+
33
+ protected _logLevels:Record<string, OINOLogLevel> = { "|||": OINOLogLevel.warning }
34
+ protected _defaultLogLevel:OINOLogLevel = OINOLogLevel.warning
35
+
36
+ /**
37
+ * Abstract logging method to implement the actual logging operation.
38
+ *
39
+ * @param logLevel default loglevel for all log events
40
+ *
41
+ */
42
+ constructor (logLevel:OINOLogLevel = OINOLogLevel.warning) {
43
+ // console.log("OINOLog.constructor: logLevel=" + logLevel)
44
+ this._logLevels["|||"] = logLevel
45
+ this._defaultLogLevel = logLevel
46
+ }
47
+
48
+
49
+ /**
50
+ * Abstract logging method to implement the actual logging operation.
51
+ *
52
+ * @param levelStr level string of the log event
53
+ * @param domain domain of the log event
54
+ * @param channel channel of the log event
55
+ * @param method method of the log event
56
+ * @param message message of the log event
57
+ * @param data structured data associated with the log event
58
+ *
59
+ */
60
+ protected abstract _writeLog(levelStr:string, domain:string, channel:string, method:string, message:string, data?:any):void
61
+
62
+ /**
63
+ * Abstract logging method to implement the actual logging operation.
64
+ *
65
+ * @param level level of the log event
66
+ * @param levelStr level string of the log event
67
+ * @param message message of the log event
68
+ * @param data structured data associated with the log event
69
+ *
70
+ */
71
+ protected static _log(level:OINOLogLevel, levelStr:string, domain:string, channel:string, method:string, message:string, data?:any):void {
72
+ if (OINOLog._instance) {
73
+ const log_levels = OINOLog._instance._logLevels
74
+ // console.log(log_levels)
75
+ const min_level =
76
+ log_levels[domain + "|" + channel + "|" + method + "|" + message] ||
77
+ log_levels[domain + "|" + channel + "|" + method + "|"] ||
78
+ log_levels[domain + "|" + channel + "||"] ||
79
+ log_levels[domain + "|||"] ||
80
+ log_levels["|||"]
81
+ // console.log("_log: level=" + level + ", min_level=" + min_level + ", levelStr=" + levelStr + ", message=" + message, data)
82
+ if (level >= min_level) {
83
+ OINOLog._instance?._writeLog(levelStr, domain, channel, method, message, data)
84
+ }
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Set active logger instance.
90
+ *
91
+ * @param instance OINOLog instance
92
+ *
93
+ */
94
+ static setInstance(instance: OINOLog) {
95
+ // console.log("setLogger: " + log)
96
+ if (instance) {
97
+ OINOLog._instance = instance
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Set log level for given combination of domain/channel/method. Not defining dimension(s) means they match any value.
103
+ * Multiple settings can be combined to set different logging accuracy specifically
104
+ *
105
+ * For example:
106
+ * logLevel: warning, domain: "", channel: "", method: "" will only output warning and higher events.
107
+ * logLevel: debug, domain: d1, channel: c1, method: "" will enable debug events for channel c1 of domain d1.
108
+ * logLevel: info, domain: d1, channel: c1, method: m1 will supress debug events for method m1.
109
+ *
110
+ * @param logLevel log level to use
111
+ * @param domain domain of the log event (default: "" for all)
112
+ * @param channel channel of the log event (default: "" for all)
113
+ * @param method method of the log event (default: "" for all)
114
+ * @param message message of the log event (default: "" for all)
115
+ */
116
+ static setLogLevel(logLevel:OINOLogLevel, domain:string = "", channel:string = "", method:string = "", message:string = "") {
117
+ if (OINOLog._instance) {
118
+ OINOLog._instance._logLevels[domain + "|" + channel + "|" + method + "|" + message] = logLevel
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Log exception event. Exception events are prettyprinted and preserve newlines so that stack traces are readable.
124
+ *
125
+ * @param domain domain of the log event
126
+ * @param channel channel of the log event
127
+ * @param method method of the log event
128
+ * @param message message of the log event
129
+ * @param data structured data associated with the log event
130
+ *
131
+ */
132
+ static exception(domain:string, channel:string, method:string, message:string, data?:any) {
133
+ OINOLog._log(OINOLogLevel.exception, "EXCEPTION", domain, channel, method, message, data)
134
+ OINOBenchmark.trackException(domain + "." + channel, method, message, data?.message || "", data?.stack || "")
135
+ }
136
+
137
+ /**
138
+ * Log error event. Error events are printed as a single line.
139
+ *
140
+ * @param domain domain of the log event
141
+ * @param channel channel of the log event
142
+ * @param method method of the log event
143
+ * @param message message of the log event
144
+ * @param data structured data associated with the log event
145
+ *
146
+ */
147
+ static error(domain:string, channel:string, method:string, message:string, data?:any) {
148
+ OINOLog._log(OINOLogLevel.error, "ERROR", domain, channel, method, message, data)
149
+ }
150
+
151
+ /**
152
+ * Log warning event. Warning events are printed as a single line.
153
+ *
154
+ * @param domain domain of the log event
155
+ * @param channel channel of the log event
156
+ * @param method method of the log event
157
+ * @param message message of the log event
158
+ * @param data structured data associated with the log event
159
+ *
160
+ */
161
+ static warning(domain:string, channel:string, method:string, message:string, data?:any) {
162
+ OINOLog._log(OINOLogLevel.warning, "WARN", domain, channel, method, message, data)
163
+ }
164
+
165
+ /**
166
+ * Log info event. Info events are printed as a single line.
167
+ *
168
+ * @param domain domain of the log event
169
+ * @param channel channel of the log event
170
+ * @param method method of the log event
171
+ * @param message message of the log event
172
+ * @param data structured data associated with the log event
173
+ *
174
+ */
175
+ static info(domain:string, channel:string, method:string, message:string, data?:any) {
176
+ OINOLog._log(OINOLogLevel.info, "INFO", domain, channel, method, message, data)
177
+ }
178
+
179
+ /**
180
+ * Log debug event. Debug events are prettyprinted.
181
+ *
182
+ * @param domain domain of the log event
183
+ * @param channel channel of the log event
184
+ * @param method method of the log event
185
+ * @param message message of the log event
186
+ * @param data structured data associated with the log event
187
+ *
188
+ */
189
+ static debug(domain:string, channel:string, method:string, message:string, data?:any) {
190
+ OINOLog._log(OINOLogLevel.debug, "DEBUG", domain, channel, method, message, data)
191
+ }
192
+
193
+ /**
194
+ * Get current log levels as an array of objects with domain, channel, method and level.
195
+ *
196
+ */
197
+ static exportLogLevels():any[] {
198
+ let result:any = []
199
+ if (OINOLog._instance) {
200
+ for (const key in OINOLog._instance._logLevels) {
201
+ const level = OINOLog._instance._logLevels[key]
202
+ if (level) {
203
+ const parts = key.split("|")
204
+ result.push({
205
+ domain: parts[0] || "",
206
+ channel: parts[1] || "",
207
+ method: parts[2] || "",
208
+ message: parts[3] || "",
209
+ level: level
210
+ })
211
+ }
212
+ }
213
+ }
214
+ return result
215
+ }
216
+
217
+
218
+ /**
219
+ * Set log levels from an array of objects with domain, channel, method and level overwriting existing values (i.e. non-existing values are not affected).
220
+ *
221
+ * @param logLevels array of log level objects
222
+ *
223
+ */
224
+ static setLogLevels(logLevels:any[]):void {
225
+ if (OINOLog._instance) {
226
+ for (const logLevel of logLevels) {
227
+ const domain = logLevel.domain || ""
228
+ const channel = logLevel.channel || ""
229
+ const method = logLevel.method || ""
230
+ const message = logLevel.message || ""
231
+ const level = logLevel.level
232
+ if (level && OINOLogLevel[level]) {
233
+ OINOLog._instance._logLevels[domain + "|" + channel + "|" + method + "|" + message] = level
234
+ }
235
+ }
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Import log levels from an array of objects with domain, channel, method and level resetting existing values (i.e. non-existing values get removed).
241
+ *
242
+ * @param logLevels array of log level objects
243
+ *
244
+ */
245
+ static importLogLevels(logLevels:any[]):void {
246
+ if (OINOLog._instance) {
247
+ OINOLog._instance._logLevels = {"|||": OINOLog._instance._defaultLogLevel} // reset to default log level
248
+ this.setLogLevels(logLevels)
249
+ }
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Logging implementation based on console.log.
255
+ *
256
+ */
257
+ export class OINOConsoleLog extends OINOLog {
258
+
259
+ /**
260
+ * Constructor of `OINOConsoleLog`
261
+ * @param logLevel logging level
262
+ */
263
+ constructor (logLevel:OINOLogLevel = OINOLogLevel.warning) {
264
+ super(logLevel)
265
+ }
266
+
267
+ protected _writeLog(level:string, domain:string, channel:string, method:string, message:string, data?:any):void {
268
+ if (message === undefined) {
269
+ console.log("OINOLog missing message: " + (new Error()).stack)
270
+ }
271
+ let log:string = "OINOLog." + level + " | " + domain + " | " + channel + " | " + method + ": " + message
272
+ let logger_func
273
+ if ((level == "ERROR") || (level == "EXCEPTION")) {
274
+ logger_func = console.error
275
+ } else if (level == "WARN") {
276
+ logger_func = console.warn
277
+ } else if (level == "INFO") {
278
+ logger_func = console.info
279
+ } else {
280
+ logger_func = console.log
281
+ }
282
+ if (data && (level == "DEBUG")) {
283
+ logger_func(log, data)
284
+ } else if (data && (level == "EXCEPTION")) {
285
+ logger_func(log + JSON.stringify(data, null, 2).replaceAll(/[^\\]\\n/g, "\n")) // preserve newlines for stack traces
286
+ } else if (data) {
287
+ logger_func(log + " " + JSON.stringify(data))
288
+ } else {
289
+ logger_func(log)
290
+ }
291
+ }
292
+ }