@oino-ts/types 0.0.18 → 0.1.1
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/{dist/types → common/src}/index.d.ts +0 -1
- package/db/src/OINODb.d.ts +180 -0
- package/db/src/OINODbApi.d.ts +82 -0
- package/db/src/OINODbConfig.d.ts +52 -0
- package/db/src/OINODbDataField.d.ts +202 -0
- package/db/src/OINODbDataModel.d.ts +108 -0
- package/db/src/OINODbDataSet.d.ts +95 -0
- package/db/src/OINODbFactory.d.ts +35 -0
- package/db/src/OINODbModelSet.d.ts +51 -0
- package/{dist/types/OINOParser.d.ts → db/src/OINODbParser.d.ts} +3 -3
- package/db/src/OINODbRequestParams.d.ts +146 -0
- package/db/src/OINODbSqlParams.d.ts +147 -0
- package/db/src/OINODbSwagger.d.ts +25 -0
- package/db/src/index.d.ts +111 -0
- package/db-bunsqlite/src/OINODbBunSqlite.d.ts +77 -0
- package/db-bunsqlite/src/index.d.ts +1 -0
- package/db-mariadb/src/OINODbMariadb.d.ts +78 -0
- package/db-mariadb/src/index.d.ts +1 -0
- package/db-mssql/src/OINODbMsSql.d.ts +86 -0
- package/db-mssql/src/index.d.ts +1 -0
- package/db-postgresql/src/OINODbPostgresql.d.ts +76 -0
- package/db-postgresql/src/index.d.ts +1 -0
- package/hashid/src/OINOHashid.d.ts +40 -0
- package/hashid/src/index.d.ts +1 -0
- package/index.d.ts +23 -0
- package/package.json +5 -8
- package/README.md +0 -190
- package/dist/cjs/OINOBenchmark.js +0 -108
- package/dist/cjs/OINOHtmlTemplate.js +0 -177
- package/dist/cjs/OINOLog.js +0 -151
- package/dist/cjs/OINOParser.js +0 -466
- package/dist/cjs/OINOResult.js +0 -216
- package/dist/cjs/OINOStr.js +0 -265
- package/dist/cjs/index.js +0 -42
- package/dist/esm/OINOBenchmark.js +0 -104
- package/dist/esm/OINOHtmlTemplate.js +0 -173
- package/dist/esm/OINOLog.js +0 -146
- package/dist/esm/OINOParser.js +0 -462
- package/dist/esm/OINOResult.js +0 -211
- package/dist/esm/OINOStr.js +0 -261
- package/dist/esm/index.js +0 -30
- package/src/OINOBenchmark.ts +0 -112
- package/src/OINOHtmlTemplate.ts +0 -186
- package/src/OINOLog.ts +0 -168
- package/src/OINOParser.ts +0 -458
- package/src/OINOResult.ts +0 -234
- package/src/OINOStr.ts +0 -254
- package/src/index.ts +0 -32
- /package/{dist/types → common/src}/OINOBenchmark.d.ts +0 -0
- /package/{dist/types → common/src}/OINOHtmlTemplate.d.ts +0 -0
- /package/{dist/types → common/src}/OINOLog.d.ts +0 -0
- /package/{dist/types → common/src}/OINOResult.d.ts +0 -0
- /package/{dist/types → common/src}/OINOStr.d.ts +0 -0
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
-
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.OINOBenchmark = void 0;
|
|
9
|
-
/**
|
|
10
|
-
* Static class for benchmarking functions.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
class OINOBenchmark {
|
|
14
|
-
static _benchmarkCount = {};
|
|
15
|
-
static _benchmarkData = {};
|
|
16
|
-
static _benchmarkEnabled = {};
|
|
17
|
-
static _benchmarkStart = {};
|
|
18
|
-
/**
|
|
19
|
-
* Reset benchmark data (but not what is enabled).
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
static reset() {
|
|
23
|
-
this._benchmarkData = {};
|
|
24
|
-
this._benchmarkCount = {};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Set benchmark names that are enabled.
|
|
28
|
-
*
|
|
29
|
-
* @param module array of those benchmarks that are enabled
|
|
30
|
-
*/
|
|
31
|
-
static setEnabled(module) {
|
|
32
|
-
this._benchmarkEnabled = {};
|
|
33
|
-
module.forEach(module_name => {
|
|
34
|
-
this._benchmarkEnabled[module_name] = true;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Start benchmark timing.
|
|
39
|
-
*
|
|
40
|
-
* @param module of the benchmark
|
|
41
|
-
* @param method of the benchmark
|
|
42
|
-
*/
|
|
43
|
-
static start(module, method) {
|
|
44
|
-
const name = module + "." + method;
|
|
45
|
-
if (this._benchmarkEnabled[module]) {
|
|
46
|
-
if (this._benchmarkCount[name] == undefined) {
|
|
47
|
-
this._benchmarkCount[name] = 0;
|
|
48
|
-
this._benchmarkData[name] = 0;
|
|
49
|
-
}
|
|
50
|
-
this._benchmarkStart[name] = performance.now();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Complete benchmark timing
|
|
55
|
-
*
|
|
56
|
-
* @param module of the benchmark
|
|
57
|
-
* @param method of the benchmark
|
|
58
|
-
* @param category optional subcategory of the benchmark
|
|
59
|
-
*/
|
|
60
|
-
static end(module, method, category) {
|
|
61
|
-
const name = module + "." + method;
|
|
62
|
-
let result = 0;
|
|
63
|
-
if (this._benchmarkEnabled[module]) {
|
|
64
|
-
const duration = performance.now() - this._benchmarkStart[name];
|
|
65
|
-
this._benchmarkCount[name] += 1;
|
|
66
|
-
this._benchmarkData[name] += duration;
|
|
67
|
-
if (category) {
|
|
68
|
-
const category_name = name + "." + category;
|
|
69
|
-
if (this._benchmarkCount[category_name] == undefined) {
|
|
70
|
-
this._benchmarkCount[category_name] = 0;
|
|
71
|
-
this._benchmarkData[category_name] = 0;
|
|
72
|
-
}
|
|
73
|
-
this._benchmarkCount[category_name] += 1;
|
|
74
|
-
this._benchmarkData[category_name] += duration;
|
|
75
|
-
}
|
|
76
|
-
result = this._benchmarkData[name] / this._benchmarkCount[name];
|
|
77
|
-
}
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get given benchmark data.
|
|
82
|
-
*
|
|
83
|
-
* @param module of the benchmark
|
|
84
|
-
* @param method of the benchmark
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
static get(module, method) {
|
|
88
|
-
const name = module + "." + method;
|
|
89
|
-
if (this._benchmarkEnabled[module]) {
|
|
90
|
-
return this._benchmarkData[module] / this._benchmarkCount[module];
|
|
91
|
-
}
|
|
92
|
-
return -1;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Get all benchmark data.
|
|
96
|
-
*
|
|
97
|
-
*/
|
|
98
|
-
static getAll() {
|
|
99
|
-
let result = {};
|
|
100
|
-
for (const name in this._benchmarkData) {
|
|
101
|
-
if (this._benchmarkCount[name] > 0) {
|
|
102
|
-
result[name] = this._benchmarkData[name] / this._benchmarkCount[name];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.OINOBenchmark = OINOBenchmark;
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OINOHtmlTemplate = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
/**
|
|
6
|
-
* Class for rendering HTML from data.
|
|
7
|
-
*/
|
|
8
|
-
class OINOHtmlTemplate {
|
|
9
|
-
_tag;
|
|
10
|
-
_tagCleanRegex;
|
|
11
|
-
_variables = {};
|
|
12
|
-
/** HTML template string */
|
|
13
|
-
template;
|
|
14
|
-
/** Cache modified value for template */
|
|
15
|
-
modified;
|
|
16
|
-
/** Cache expiration value for template */
|
|
17
|
-
expires;
|
|
18
|
-
/**
|
|
19
|
-
* Creates HTML Response from a key-value-pair.
|
|
20
|
-
*
|
|
21
|
-
* @param template template string
|
|
22
|
-
* @param tag tag to identify variables in template
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
constructor(template, tag = "###") {
|
|
26
|
-
this.template = template;
|
|
27
|
-
this.modified = 0;
|
|
28
|
-
this.expires = 0;
|
|
29
|
-
this._tag = tag;
|
|
30
|
-
this._tagCleanRegex = new RegExp(tag + ".*" + tag, "g");
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @returns whether template is empty
|
|
34
|
-
*/
|
|
35
|
-
isEmpty() {
|
|
36
|
-
return this.template == "";
|
|
37
|
-
}
|
|
38
|
-
_createHttpResult(html, removeUnusedTags) {
|
|
39
|
-
if (removeUnusedTags) {
|
|
40
|
-
html = html.replace(this._tagCleanRegex, "");
|
|
41
|
-
}
|
|
42
|
-
const result = new _1.OINOHttpResult(html);
|
|
43
|
-
if (this.expires >= 1) {
|
|
44
|
-
result.expires = Math.round(this.expires);
|
|
45
|
-
}
|
|
46
|
-
if (this.modified >= 1) {
|
|
47
|
-
result.lastModified = this.modified;
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
_renderHtml() {
|
|
52
|
-
let html = this.template;
|
|
53
|
-
for (let key in this._variables) {
|
|
54
|
-
const value = this._variables[key];
|
|
55
|
-
html = html.replaceAll(this._tag + key + this._tag, value);
|
|
56
|
-
}
|
|
57
|
-
return html;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Clear template variables.
|
|
61
|
-
*
|
|
62
|
-
*/
|
|
63
|
-
clearVariables() {
|
|
64
|
-
this._variables = {};
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Sets template variable from a key-value-pair.
|
|
68
|
-
*
|
|
69
|
-
* @param variable key
|
|
70
|
-
* @param value value
|
|
71
|
-
* @param escapeValue whether to escape value
|
|
72
|
-
*
|
|
73
|
-
*/
|
|
74
|
-
setVariableFromValue(variable, value, escapeValue = true) {
|
|
75
|
-
if (escapeValue) {
|
|
76
|
-
value = _1.OINOStr.encode(value, _1.OINOContentType.html);
|
|
77
|
-
}
|
|
78
|
-
this._variables[variable] = value;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Sets template variables from object properties.
|
|
82
|
-
*
|
|
83
|
-
* @param object any object
|
|
84
|
-
* @param escapeValue whether to escape value
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
setVariableFromProperties(object, escapeValue = true) {
|
|
88
|
-
if (object) {
|
|
89
|
-
for (let key in object) {
|
|
90
|
-
if (escapeValue) {
|
|
91
|
-
this._variables[key] = _1.OINOStr.encode(object[key], _1.OINOContentType.html);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this._variables[key] = object[key];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Creates HTML Response from set variables.
|
|
101
|
-
*
|
|
102
|
-
* @param removeUnusedTags whether to remove unused tags
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
render(removeUnusedTags = true) {
|
|
106
|
-
return this._createHttpResult(this._renderHtml(), removeUnusedTags);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Creates HTML Response from a key-value-pair.
|
|
110
|
-
*
|
|
111
|
-
* @param key key
|
|
112
|
-
* @param value value
|
|
113
|
-
* @param removeUnusedTags whether to remove unused tags
|
|
114
|
-
*
|
|
115
|
-
*/
|
|
116
|
-
renderFromKeyValue(key, value, removeUnusedTags = true) {
|
|
117
|
-
_1.OINOBenchmark.start("OINOHtmlTemplate", "renderFromKeyValue");
|
|
118
|
-
this.setVariableFromValue(key, value);
|
|
119
|
-
const result = this.render(removeUnusedTags);
|
|
120
|
-
_1.OINOBenchmark.end("OINOHtmlTemplate", "renderFromKeyValue");
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Creates HTML Response from object properties.
|
|
125
|
-
*
|
|
126
|
-
* @param object object
|
|
127
|
-
* @param removeUnusedTags whether to remove unused tags
|
|
128
|
-
*
|
|
129
|
-
*/
|
|
130
|
-
renderFromObject(object, removeUnusedTags = true) {
|
|
131
|
-
_1.OINOBenchmark.start("OINOHtmlTemplate", "renderFromObject");
|
|
132
|
-
this.setVariableFromProperties(object);
|
|
133
|
-
const result = this.render(removeUnusedTags);
|
|
134
|
-
_1.OINOBenchmark.end("OINOHtmlTemplate", "renderFromObject");
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Creates HTML Response from API result.
|
|
139
|
-
*
|
|
140
|
-
* @param result OINOResult-object
|
|
141
|
-
* @param removeUnusedTags whether to remove unused tags
|
|
142
|
-
* @param messageSeparator HTML separator for messages
|
|
143
|
-
* @param includeErrorMessages include debug messages in result
|
|
144
|
-
* @param includeWarningMessages include debug messages in result
|
|
145
|
-
* @param includeInfoMessages include debug messages in result
|
|
146
|
-
* @param includeDebugMessages include debug messages in result
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
renderFromResult(result, removeUnusedTags = true, messageSeparator, includeErrorMessages = false, includeWarningMessages = false, includeInfoMessages = false, includeDebugMessages = false) {
|
|
150
|
-
_1.OINOBenchmark.start("OINOHtmlTemplate", "renderFromResult");
|
|
151
|
-
this.setVariableFromValue("statusCode", result.statusCode.toString());
|
|
152
|
-
this.setVariableFromValue("statusMessage", result.statusMessage.toString());
|
|
153
|
-
let messages = [];
|
|
154
|
-
for (let i = 0; i < result.messages.length; i++) {
|
|
155
|
-
if (includeErrorMessages && result.messages[i].startsWith(_1.OINO_ERROR_PREFIX)) {
|
|
156
|
-
messages.push(_1.OINOStr.encode(result.messages[i], _1.OINOContentType.html));
|
|
157
|
-
}
|
|
158
|
-
if (includeWarningMessages && result.messages[i].startsWith(_1.OINO_WARNING_PREFIX)) {
|
|
159
|
-
messages.push(_1.OINOStr.encode(result.messages[i], _1.OINOContentType.html));
|
|
160
|
-
}
|
|
161
|
-
if (includeInfoMessages && result.messages[i].startsWith(_1.OINO_INFO_PREFIX)) {
|
|
162
|
-
messages.push(_1.OINOStr.encode(result.messages[i], _1.OINOContentType.html));
|
|
163
|
-
}
|
|
164
|
-
if (includeDebugMessages && result.messages[i].startsWith(_1.OINO_DEBUG_PREFIX)) {
|
|
165
|
-
messages.push(_1.OINOStr.encode(result.messages[i], _1.OINOContentType.html));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (messages.length > 0) {
|
|
169
|
-
this.setVariableFromValue("messages", messages.join(messageSeparator), false); // messages have been escaped already
|
|
170
|
-
}
|
|
171
|
-
const http_result = this.render(removeUnusedTags);
|
|
172
|
-
_1.OINOBenchmark.end("OINOHtmlTemplate", "renderFromResult");
|
|
173
|
-
return http_result;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.OINOHtmlTemplate = OINOHtmlTemplate;
|
|
177
|
-
;
|
package/dist/cjs/OINOLog.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
-
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.OINOConsoleLog = exports.OINOLog = exports.OINOLogLevel = void 0;
|
|
9
|
-
/** Logging levels */
|
|
10
|
-
var OINOLogLevel;
|
|
11
|
-
(function (OINOLogLevel) {
|
|
12
|
-
/** Debug messages */
|
|
13
|
-
OINOLogLevel[OINOLogLevel["debug"] = 0] = "debug";
|
|
14
|
-
/** Informational messages */
|
|
15
|
-
OINOLogLevel[OINOLogLevel["info"] = 1] = "info";
|
|
16
|
-
/** Warning messages */
|
|
17
|
-
OINOLogLevel[OINOLogLevel["warn"] = 2] = "warn";
|
|
18
|
-
/** Error messages */
|
|
19
|
-
OINOLogLevel[OINOLogLevel["error"] = 3] = "error";
|
|
20
|
-
})(OINOLogLevel || (exports.OINOLogLevel = OINOLogLevel = {}));
|
|
21
|
-
/**
|
|
22
|
-
* Abstract base class for logging implementations supporting
|
|
23
|
-
* - error, warning, info and debug channels
|
|
24
|
-
* - setting level of logs outputted
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
class OINOLog {
|
|
28
|
-
static _instance;
|
|
29
|
-
_logLevel = OINOLogLevel.warn;
|
|
30
|
-
/**
|
|
31
|
-
* Abstract logging method to implement the actual logging operation.
|
|
32
|
-
*
|
|
33
|
-
* @param logLevel level of the log events
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
constructor(logLevel = OINOLogLevel.warn) {
|
|
37
|
-
// console.log("OINOLog.constructor: logLevel=" + logLevel)
|
|
38
|
-
this._logLevel = logLevel;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Abstract logging method to implement the actual logging operation.
|
|
42
|
-
*
|
|
43
|
-
* @param level level of the log event
|
|
44
|
-
* @param levelStr level string of the log event
|
|
45
|
-
* @param message message of the log event
|
|
46
|
-
* @param data structured data associated with the log event
|
|
47
|
-
*
|
|
48
|
-
*/
|
|
49
|
-
static _log(level, levelStr, message, data) {
|
|
50
|
-
// console.log("_log: level=" + level + ", levelStr=" + levelStr + ", message=" + message + ", data=" + data)
|
|
51
|
-
if ((OINOLog._instance) && (OINOLog._instance._logLevel <= level)) {
|
|
52
|
-
OINOLog._instance?._writeLog(levelStr, message, data);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Set active logger and log level.
|
|
57
|
-
*
|
|
58
|
-
* @param logger logger instance
|
|
59
|
-
*
|
|
60
|
-
*/
|
|
61
|
-
static setLogger(logger) {
|
|
62
|
-
// console.log("setLogger: " + log)
|
|
63
|
-
if (logger) {
|
|
64
|
-
OINOLog._instance = logger;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Set log level.
|
|
69
|
-
*
|
|
70
|
-
* @param logLevel log level to use
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
static setLogLevel(logLevel) {
|
|
74
|
-
if (OINOLog._instance) {
|
|
75
|
-
OINOLog._instance._logLevel = logLevel;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Log error event.
|
|
80
|
-
*
|
|
81
|
-
* @param message message of the log event
|
|
82
|
-
* @param data structured data associated with the log event
|
|
83
|
-
*
|
|
84
|
-
*/
|
|
85
|
-
static error(message, data) {
|
|
86
|
-
OINOLog._log(OINOLogLevel.error, "ERROR", message, data);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Log warning event.
|
|
90
|
-
*
|
|
91
|
-
* @param message message of the log event
|
|
92
|
-
* @param data structured data associated with the log event
|
|
93
|
-
*
|
|
94
|
-
*/
|
|
95
|
-
static warning(message, data) {
|
|
96
|
-
OINOLog._log(OINOLogLevel.warn, "WARN", message, data);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Log info event.
|
|
100
|
-
*
|
|
101
|
-
* @param message message of the log event
|
|
102
|
-
* @param data structured data associated with the log event
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
static info(message, data) {
|
|
106
|
-
OINOLog._log(OINOLogLevel.info, "INFO", message, data);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Log debug event.
|
|
110
|
-
*
|
|
111
|
-
* @param message message of the log event
|
|
112
|
-
* @param data structured data associated with the log event
|
|
113
|
-
*
|
|
114
|
-
*/
|
|
115
|
-
static debug(message, data) {
|
|
116
|
-
OINOLog._log(OINOLogLevel.debug, "DEBUG", message, data);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.OINOLog = OINOLog;
|
|
120
|
-
/**
|
|
121
|
-
* Logging implementation based on console.log.
|
|
122
|
-
*
|
|
123
|
-
*/
|
|
124
|
-
class OINOConsoleLog extends OINOLog {
|
|
125
|
-
/**
|
|
126
|
-
* Constructor of `OINOConsoleLog`
|
|
127
|
-
* @param logLevel logging level
|
|
128
|
-
*/
|
|
129
|
-
constructor(logLevel = OINOLogLevel.warn) {
|
|
130
|
-
super(logLevel);
|
|
131
|
-
}
|
|
132
|
-
_writeLog(level, message, data) {
|
|
133
|
-
let log = "OINOLog " + level + ": " + message;
|
|
134
|
-
if (data) {
|
|
135
|
-
log += " " + JSON.stringify(data);
|
|
136
|
-
}
|
|
137
|
-
if (level == "ERROR") {
|
|
138
|
-
console.error(log);
|
|
139
|
-
}
|
|
140
|
-
else if (level == "WARN") {
|
|
141
|
-
console.warn(log);
|
|
142
|
-
}
|
|
143
|
-
else if (level == "INFO") {
|
|
144
|
-
console.info(log);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
console.log(log);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
exports.OINOConsoleLog = OINOConsoleLog;
|