@iobroker/js-controller-common-db 7.2.3 → 8.0.0-alpha.2-20260923-99da17fcc
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/build/cjs/index.js +3 -3
- package/build/cjs/lib/common/aliasProcessing.js +6 -0
- package/build/cjs/lib/common/aliasProcessing.js.map +2 -2
- package/build/cjs/lib/common/interview.js +2 -0
- package/build/cjs/lib/common/interview.js.map +1 -1
- package/build/cjs/lib/common/logger.d.ts +34 -1
- package/build/cjs/lib/common/logger.js +37 -37
- package/build/cjs/lib/common/logger.js.map +2 -2
- package/build/cjs/lib/common/maybeCallback.js +4 -0
- package/build/cjs/lib/common/maybeCallback.js.map +1 -1
- package/build/cjs/lib/common/password.d.ts +9 -0
- package/build/cjs/lib/common/password.js +8 -6
- package/build/cjs/lib/common/password.js.map +2 -2
- package/build/cjs/lib/common/session.js +10 -5
- package/build/cjs/lib/common/session.js.map +2 -2
- package/build/cjs/lib/common/tools.d.ts +187 -59
- package/build/cjs/lib/common/tools.js +522 -476
- package/build/cjs/lib/common/tools.js.map +3 -3
- package/build/esm/lib/common/aliasProcessing.d.ts.map +1 -1
- package/build/esm/lib/common/aliasProcessing.js +5 -0
- package/build/esm/lib/common/aliasProcessing.js.map +1 -1
- package/build/esm/lib/common/logger.d.ts +34 -1
- package/build/esm/lib/common/logger.d.ts.map +1 -1
- package/build/esm/lib/common/logger.js +45 -49
- package/build/esm/lib/common/logger.js.map +1 -1
- package/build/esm/lib/common/password.d.ts +9 -0
- package/build/esm/lib/common/password.d.ts.map +1 -1
- package/build/esm/lib/common/password.js +5 -0
- package/build/esm/lib/common/password.js.map +1 -1
- package/build/esm/lib/common/session.d.ts.map +1 -1
- package/build/esm/lib/common/session.js +6 -6
- package/build/esm/lib/common/session.js.map +1 -1
- package/build/esm/lib/common/tools.d.ts +187 -59
- package/build/esm/lib/common/tools.d.ts.map +1 -1
- package/build/esm/lib/common/tools.js +580 -586
- package/build/esm/lib/common/tools.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +18 -18
package/build/cjs/index.js
CHANGED
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
31
|
EXIT_CODES: () => import_exitCodes.EXIT_CODES,
|
|
32
32
|
constants: () => constants,
|
|
33
33
|
defaultRedisInterview: () => import_interview.defaultRedisInterview,
|
|
@@ -36,7 +36,7 @@ __export(esm_exports, {
|
|
|
36
36
|
session: () => import_session.createAdapterStore,
|
|
37
37
|
tools: () => tools
|
|
38
38
|
});
|
|
39
|
-
module.exports = __toCommonJS(
|
|
39
|
+
module.exports = __toCommonJS(index_exports);
|
|
40
40
|
var tools = __toESM(require("./lib/common/tools.js"), 1);
|
|
41
41
|
var import_exitCodes = require("./lib/common/exitCodes.js");
|
|
42
42
|
var import_password = require("./lib/common/password.js");
|
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -29,6 +30,7 @@ function applyAliasTransformer(options) {
|
|
|
29
30
|
const func = new Function("val", "type", "min", "max", `${prefix}Type`, `${prefix}Min`, `${prefix}Max`, `return ${transformer}`);
|
|
30
31
|
return func(state.val, firstCommon.type, firstCommon.min, firstCommon.max, secondCommon.type, secondCommon.min, secondCommon.max);
|
|
31
32
|
}
|
|
33
|
+
__name(applyAliasTransformer, "applyAliasTransformer");
|
|
32
34
|
function applyAliasConvenienceConversion(options) {
|
|
33
35
|
const { targetCommon, state } = options;
|
|
34
36
|
if (targetCommon && typeof state.val !== targetCommon.type && state.val !== null && state.val !== void 0) {
|
|
@@ -40,12 +42,15 @@ function applyAliasConvenienceConversion(options) {
|
|
|
40
42
|
return !!state.val;
|
|
41
43
|
} else if (targetCommon.type === "number" && typeof state.val === "string") {
|
|
42
44
|
return parseFloat(state.val);
|
|
45
|
+
} else if (targetCommon.type === "number" && typeof state.val === "boolean") {
|
|
46
|
+
return state.val ? 1 : 0;
|
|
43
47
|
} else if (targetCommon.type === "string") {
|
|
44
48
|
return state.val.toString();
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
return state.val;
|
|
48
52
|
}
|
|
53
|
+
__name(applyAliasConvenienceConversion, "applyAliasConvenienceConversion");
|
|
49
54
|
function applyAliasAutoScaling(options) {
|
|
50
55
|
const { state, sourceCommon, targetCommon } = options;
|
|
51
56
|
if ((targetCommon?.alias && !targetCommon.alias.read || sourceCommon?.alias && !sourceCommon.alias.write) && state.val !== null) {
|
|
@@ -57,6 +62,7 @@ function applyAliasAutoScaling(options) {
|
|
|
57
62
|
}
|
|
58
63
|
return state.val;
|
|
59
64
|
}
|
|
65
|
+
__name(applyAliasAutoScaling, "applyAliasAutoScaling");
|
|
60
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
67
|
0 && (module.exports = {
|
|
62
68
|
applyAliasAutoScaling,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/common/aliasProcessing.ts"],
|
|
4
|
-
"sourcesContent": ["interface ApplyAliasTransformerOptions {\n /** State used for calculations */\n state: ioBroker.State;\n /** Properties from this StateCommon will be provided first to the conversion function */\n firstCommon: Partial<ioBroker.StateCommon>;\n /** Properties from this StateCommon will be provided second to the conversion function */\n secondCommon: Partial<ioBroker.StateCommon>;\n /** The actual transformer function as a string */\n transformer: string;\n /** If this is a read function, determines the naming of the passed variables */\n isRead: boolean;\n}\n\ninterface ApplyAliasConvenienceConversionOptions {\n /** State used for calculations */\n state: ioBroker.State;\n /** The common attribute of the alias target */\n targetCommon?: Partial<ioBroker.StateCommon>;\n}\n\ninterface ApplyAliasAutoScalingOptions extends ApplyAliasConvenienceConversionOptions {\n /** The common attribute of the alias source */\n sourceCommon?: Partial<ioBroker.StateCommon>;\n}\n\n/**\n * Applies a user-given transformer function and provides the type, min and max of the\n * passed StateCommon variables as well as the state's value\n *\n * @param options state, common information and transformer function\n */\nexport function applyAliasTransformer(options: ApplyAliasTransformerOptions): ioBroker.StateValue {\n const { state, firstCommon, secondCommon, transformer, isRead } = options;\n\n const prefix = isRead ? 's' : 't';\n\n const func = new Function(\n 'val',\n 'type',\n 'min',\n 'max',\n `${prefix}Type`,\n `${prefix}Min`,\n `${prefix}Max`,\n `return ${transformer}`,\n );\n\n return func(\n state.val,\n firstCommon.type,\n firstCommon.min,\n firstCommon.max,\n secondCommon.type,\n secondCommon.min,\n secondCommon.max,\n );\n}\n\n/**\n * Applies some convenience conversions of aliases, e.g. transforming string 'off' to a boolean false, if target is a boolean\n *\n * @param options state and target common information\n */\nexport function applyAliasConvenienceConversion(options: ApplyAliasConvenienceConversionOptions): ioBroker.StateValue {\n const { targetCommon, state } = options;\n\n if (targetCommon && typeof state.val !== targetCommon.type && state.val !== null && state.val !== undefined) {\n if (targetCommon.type === 'boolean') {\n const lowerVal = typeof state.val === 'string' ? state.val.toLowerCase() : state.val;\n if (lowerVal === 'off' || lowerVal === 'aus' || state.val === '0') {\n return false;\n }\n // this also handles strings like \"EIN\" or such that will be true\n return !!state.val;\n } else if (targetCommon.type === 'number' && typeof state.val === 'string') {\n return parseFloat(state.val);\n } else if (targetCommon.type === 'string') {\n return state.val.toString();\n }\n }\n\n return state.val;\n}\n\n/**\n * Applies autoscaling between alias source and target if one has % unit and the other not\n *\n * @param options state, source and target common information\n */\nexport function applyAliasAutoScaling(options: ApplyAliasAutoScalingOptions): ioBroker.StateValue {\n const { state, sourceCommon, targetCommon } = options;\n\n // auto-scaling, only if val not null and unit for target (x)or source is %\n if (\n ((targetCommon?.alias && !targetCommon.alias.read) || (sourceCommon?.alias && !sourceCommon.alias.write)) &&\n state.val !== null\n ) {\n if (\n targetCommon &&\n targetCommon.type === 'number' &&\n targetCommon.unit === '%' &&\n sourceCommon &&\n sourceCommon.type === 'number' &&\n sourceCommon.unit !== '%' &&\n sourceCommon.min !== undefined &&\n sourceCommon.max !== undefined\n ) {\n // scale target between 0 and 100 % based on sources min/max\n return (((state.val as number) - sourceCommon.min) / (sourceCommon.max - sourceCommon.min)) * 100;\n } else if (\n sourceCommon &&\n sourceCommon.type === 'number' &&\n sourceCommon.unit === '%' &&\n targetCommon &&\n targetCommon.unit !== '%' &&\n targetCommon.type === 'number' &&\n targetCommon.min !== undefined &&\n targetCommon.max !== undefined\n ) {\n // scale target based on its min/max by its source (assuming source is meant to be 0 - 100 %)\n return ((targetCommon.max - targetCommon.min) * (state.val as number)) / 100 + targetCommon.min;\n }\n }\n\n return state.val;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["interface ApplyAliasTransformerOptions {\n /** State used for calculations */\n state: ioBroker.State;\n /** Properties from this StateCommon will be provided first to the conversion function */\n firstCommon: Partial<ioBroker.StateCommon>;\n /** Properties from this StateCommon will be provided second to the conversion function */\n secondCommon: Partial<ioBroker.StateCommon>;\n /** The actual transformer function as a string */\n transformer: string;\n /** If this is a read function, determines the naming of the passed variables */\n isRead: boolean;\n}\n\ninterface ApplyAliasConvenienceConversionOptions {\n /** State used for calculations */\n state: ioBroker.State;\n /** The common attribute of the alias target */\n targetCommon?: Partial<ioBroker.StateCommon>;\n}\n\ninterface ApplyAliasAutoScalingOptions extends ApplyAliasConvenienceConversionOptions {\n /** The common attribute of the alias source */\n sourceCommon?: Partial<ioBroker.StateCommon>;\n}\n\n/**\n * Applies a user-given transformer function and provides the type, min and max of the\n * passed StateCommon variables as well as the state's value\n *\n * @param options state, common information and transformer function\n */\nexport function applyAliasTransformer(options: ApplyAliasTransformerOptions): ioBroker.StateValue {\n const { state, firstCommon, secondCommon, transformer, isRead } = options;\n\n const prefix = isRead ? 's' : 't';\n\n const func = new Function(\n 'val',\n 'type',\n 'min',\n 'max',\n `${prefix}Type`,\n `${prefix}Min`,\n `${prefix}Max`,\n `return ${transformer}`,\n );\n\n return func(\n state.val,\n firstCommon.type,\n firstCommon.min,\n firstCommon.max,\n secondCommon.type,\n secondCommon.min,\n secondCommon.max,\n );\n}\n\n/**\n * Applies some convenience conversions of aliases, e.g. transforming string 'off' to a boolean false, if target is a boolean\n *\n * @param options state and target common information\n */\nexport function applyAliasConvenienceConversion(options: ApplyAliasConvenienceConversionOptions): ioBroker.StateValue {\n const { targetCommon, state } = options;\n\n if (targetCommon && typeof state.val !== targetCommon.type && state.val !== null && state.val !== undefined) {\n if (targetCommon.type === 'boolean') {\n const lowerVal = typeof state.val === 'string' ? state.val.toLowerCase() : state.val;\n if (lowerVal === 'off' || lowerVal === 'aus' || state.val === '0') {\n return false;\n }\n // this also handles strings like \"EIN\" or such that will be true\n return !!state.val;\n } else if (targetCommon.type === 'number' && typeof state.val === 'string') {\n return parseFloat(state.val);\n } else if (targetCommon.type === 'number' && typeof state.val === 'boolean') {\n // a read/write function may return a comparison result (e.g. \"val < 20\") for a\n // numeric alias \u2014 store it as 1/0 instead of leaving a boolean in a number state\n return state.val ? 1 : 0;\n } else if (targetCommon.type === 'string') {\n return state.val.toString();\n }\n }\n\n return state.val;\n}\n\n/**\n * Applies autoscaling between alias source and target if one has % unit and the other not\n *\n * @param options state, source and target common information\n */\nexport function applyAliasAutoScaling(options: ApplyAliasAutoScalingOptions): ioBroker.StateValue {\n const { state, sourceCommon, targetCommon } = options;\n\n // auto-scaling, only if val not null and unit for target (x)or source is %\n if (\n ((targetCommon?.alias && !targetCommon.alias.read) || (sourceCommon?.alias && !sourceCommon.alias.write)) &&\n state.val !== null\n ) {\n if (\n targetCommon &&\n targetCommon.type === 'number' &&\n targetCommon.unit === '%' &&\n sourceCommon &&\n sourceCommon.type === 'number' &&\n sourceCommon.unit !== '%' &&\n sourceCommon.min !== undefined &&\n sourceCommon.max !== undefined\n ) {\n // scale target between 0 and 100 % based on sources min/max\n return (((state.val as number) - sourceCommon.min) / (sourceCommon.max - sourceCommon.min)) * 100;\n } else if (\n sourceCommon &&\n sourceCommon.type === 'number' &&\n sourceCommon.unit === '%' &&\n targetCommon &&\n targetCommon.unit !== '%' &&\n targetCommon.type === 'number' &&\n targetCommon.min !== undefined &&\n targetCommon.max !== undefined\n ) {\n // scale target based on its min/max by its source (assuming source is meant to be 0 - 100 %)\n return ((targetCommon.max - targetCommon.min) * (state.val as number)) / 100 + targetCommon.min;\n }\n }\n\n return state.val;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAyBA;;;;;;;AAMM,SAAU,sBAAsB,SAAqC;AACvE,QAAM,EAAE,OAAO,aAAa,cAAc,aAAa,OAAM,IAAK;AAElE,QAAM,SAAS,SAAS,MAAM;AAE9B,QAAM,OAAO,IAAI,SACb,OACA,QACA,OACA,OACA,GAAG,MAAM,QACT,GAAG,MAAM,OACT,GAAG,MAAM,OACT,UAAU,WAAW,EAAE;AAG3B,SAAO,KACH,MAAM,KACN,YAAY,MACZ,YAAY,KACZ,YAAY,KACZ,aAAa,MACb,aAAa,KACb,aAAa,GAAG;AAExB;AAzBgB;AAgCV,SAAU,gCAAgC,SAA+C;AAC3F,QAAM,EAAE,cAAc,MAAK,IAAK;AAEhC,MAAI,gBAAgB,OAAO,MAAM,QAAQ,aAAa,QAAQ,MAAM,QAAQ,QAAQ,MAAM,QAAQ,QAAW;AACzG,QAAI,aAAa,SAAS,WAAW;AACjC,YAAM,WAAW,OAAO,MAAM,QAAQ,WAAW,MAAM,IAAI,YAAW,IAAK,MAAM;AACjF,UAAI,aAAa,SAAS,aAAa,SAAS,MAAM,QAAQ,KAAK;AAC/D,eAAO;MACX;AAEA,aAAO,CAAC,CAAC,MAAM;IACnB,WAAW,aAAa,SAAS,YAAY,OAAO,MAAM,QAAQ,UAAU;AACxE,aAAO,WAAW,MAAM,GAAG;IAC/B,WAAW,aAAa,SAAS,YAAY,OAAO,MAAM,QAAQ,WAAW;AAGzE,aAAO,MAAM,MAAM,IAAI;IAC3B,WAAW,aAAa,SAAS,UAAU;AACvC,aAAO,MAAM,IAAI,SAAQ;IAC7B;EACJ;AAEA,SAAO,MAAM;AACjB;AAvBgB;AA8BV,SAAU,sBAAsB,SAAqC;AACvE,QAAM,EAAE,OAAO,cAAc,aAAY,IAAK;AAG9C,OACM,cAAc,SAAS,CAAC,aAAa,MAAM,QAAU,cAAc,SAAS,CAAC,aAAa,MAAM,UAClG,MAAM,QAAQ,MAChB;AACE,QACI,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,aAAa,QAAQ,UACrB,aAAa,QAAQ,QACvB;AAEE,cAAU,MAAM,MAAiB,aAAa,QAAQ,aAAa,MAAM,aAAa,OAAQ;IAClG,WACI,gBACA,aAAa,SAAS,YACtB,aAAa,SAAS,OACtB,gBACA,aAAa,SAAS,OACtB,aAAa,SAAS,YACtB,aAAa,QAAQ,UACrB,aAAa,QAAQ,QACvB;AAEE,cAAS,aAAa,MAAM,aAAa,OAAQ,MAAM,MAAkB,MAAM,aAAa;IAChG;EACJ;AAEA,SAAO,MAAM;AACjB;AApCgB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
10
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -80,6 +81,7 @@ async function defaultRedisInterview(options) {
|
|
|
80
81
|
} while (!config.options.tls.ca);
|
|
81
82
|
return config;
|
|
82
83
|
}
|
|
84
|
+
__name(defaultRedisInterview, "defaultRedisInterview");
|
|
83
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
86
|
0 && (module.exports = {
|
|
85
87
|
defaultRedisInterview
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/common/interview.ts"],
|
|
4
4
|
"sourcesContent": ["import rl from 'readline-sync';\nimport fs from 'fs-extra';\n\n/** Regex to limit inputs to yes/no shortcuts */\nconst YES_NO_REGEX = /^[YyNn]?$/;\n\ntype SharedDatabaseOptions = ioBroker.ObjectsDatabaseOptions | ioBroker.StatesDatabaseOptions;\n\ninterface DefaultRedisInterviewOptions<TConfig extends SharedDatabaseOptions> {\n /** Database type */\n type: 'objects' | 'states';\n /** Prefilled config */\n config: TConfig;\n}\n\n/**\n * The default redis interview shared between objects and states\n *\n * @param options config and type information\n */\nexport async function defaultRedisInterview<TConfig extends SharedDatabaseOptions>(\n options: DefaultRedisInterviewOptions<TConfig>,\n): Promise<TConfig> {\n const { type, config } = options;\n\n let answer = rl.question(`Do you use a TLS connection for your \"${type}\" redis-server? [y/N]:`, {\n limit: YES_NO_REGEX,\n defaultInput: 'N',\n });\n\n if (answer.toLowerCase() === 'n') {\n return config;\n }\n\n config.options.tls = {};\n\n answer = rl.question(`Do you use a self-signed certificate for your \"${type}\" redis-server? [y/N]:`, {\n limit: YES_NO_REGEX,\n defaultInput: 'N',\n });\n\n if (answer.toLowerCase() === 'y') {\n config.options.tls.rejectUnauthorized = false;\n }\n\n do {\n answer = rl.question(`Please specify the path to your \"${type}\" redis-server \"certificate\" file:`);\n\n try {\n const certContent = await fs.readFile(answer, { encoding: 'utf8' });\n config.options.tls.cert = certContent;\n } catch (e) {\n console.warn(`Could not read the \"certificate\" file: ${e.message}`);\n }\n } while (!config.options.tls.cert);\n\n do {\n answer = rl.question(`Please specify the path to your \"${type}\" redis-server \"key\" file:`);\n\n try {\n const keyContent = await fs.readFile(answer, { encoding: 'utf8' });\n config.options.tls.key = keyContent;\n } catch (e) {\n console.warn(`Could not read the \"key\" file: ${e.message}`);\n }\n } while (!config.options.tls.key);\n\n do {\n answer = rl.question(`Please specify the path to your \"${type}\" redis-server \"CA\" file:`);\n\n try {\n const caContent = await fs.readFile(answer, { encoding: 'utf8' });\n config.options.tls.ca = caContent;\n } catch (e) {\n console.warn(`Could not read the \"CA\" file: ${e.message}`);\n }\n } while (!config.options.tls.ca);\n\n return config;\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,2BAAe;AACf,sBAAe;AAGf,MAAM,eAAe;AAgBrB,eAAsB,sBAClB,SAA8C;AAE9C,QAAM,EAAE,MAAM,OAAM,IAAK;AAEzB,MAAI,SAAS,qBAAAA,QAAG,SAAS,yCAAyC,IAAI,0BAA0B;IAC5F,OAAO;IACP,cAAc;GACjB;AAED,MAAI,OAAO,YAAW,MAAO,KAAK;AAC9B,WAAO;EACX;AAEA,SAAO,QAAQ,MAAM,CAAA;AAErB,WAAS,qBAAAA,QAAG,SAAS,kDAAkD,IAAI,0BAA0B;IACjG,OAAO;IACP,cAAc;GACjB;AAED,MAAI,OAAO,YAAW,MAAO,KAAK;AAC9B,WAAO,QAAQ,IAAI,qBAAqB;EAC5C;AAEA,KAAG;AACC,aAAS,qBAAAA,QAAG,SAAS,oCAAoC,IAAI,oCAAoC;AAEjG,QAAI;AACA,YAAM,cAAc,MAAM,gBAAAC,QAAG,SAAS,QAAQ,EAAE,UAAU,OAAM,CAAE;AAClE,aAAO,QAAQ,IAAI,OAAO;IAC9B,SAAS,GAAG;AACR,cAAQ,KAAK,0CAA0C,EAAE,OAAO,EAAE;IACtE;EACJ,SAAS,CAAC,OAAO,QAAQ,IAAI;AAE7B,KAAG;AACC,aAAS,qBAAAD,QAAG,SAAS,oCAAoC,IAAI,4BAA4B;AAEzF,QAAI;AACA,YAAM,aAAa,MAAM,gBAAAC,QAAG,SAAS,QAAQ,EAAE,UAAU,OAAM,CAAE;AACjE,aAAO,QAAQ,IAAI,MAAM;IAC7B,SAAS,GAAG;AACR,cAAQ,KAAK,kCAAkC,EAAE,OAAO,EAAE;IAC9D;EACJ,SAAS,CAAC,OAAO,QAAQ,IAAI;AAE7B,KAAG;AACC,aAAS,qBAAAD,QAAG,SAAS,oCAAoC,IAAI,2BAA2B;AAExF,QAAI;AACA,YAAM,YAAY,MAAM,gBAAAC,QAAG,SAAS,QAAQ,EAAE,UAAU,OAAM,CAAE;AAChE,aAAO,QAAQ,IAAI,KAAK;IAC5B,SAAS,GAAG;AACR,cAAQ,KAAK,iCAAiC,EAAE,OAAO,EAAE;IAC7D;EACJ,SAAS,CAAC,OAAO,QAAQ,IAAI;AAE7B,SAAO;AACX;AA3DsB;",
|
|
6
6
|
"names": ["rl", "fs"]
|
|
7
7
|
}
|
|
@@ -1,14 +1,47 @@
|
|
|
1
1
|
import winston from 'winston';
|
|
2
|
-
|
|
2
|
+
import type { TransformableInfo } from 'logform';
|
|
3
|
+
/** Log entry enriched with ioBroker specific properties */
|
|
4
|
+
export interface LogInfo extends TransformableInfo {
|
|
5
|
+
/** The log message text */
|
|
6
|
+
message: string;
|
|
7
|
+
/** Additional properties attached to the log entry */
|
|
8
|
+
props?: {
|
|
9
|
+
/** The host the log entry originates from */
|
|
10
|
+
Hostname?: string;
|
|
11
|
+
/** The source (adapter/instance) of the log entry */
|
|
12
|
+
Source?: string;
|
|
13
|
+
/** The process id that produced the log entry */
|
|
14
|
+
Pid?: string;
|
|
15
|
+
};
|
|
16
|
+
/** ISO timestamp of the log entry */
|
|
17
|
+
timestamp: string;
|
|
18
|
+
}
|
|
19
|
+
/** Logger configuration options provided by the user */
|
|
3
20
|
export interface UserOptions {
|
|
21
|
+
/** Minimum log level to output (e.g. silly, debug, info, warn, error) */
|
|
4
22
|
level: string;
|
|
23
|
+
/** Maximum number of days rotated log files are kept before deletion */
|
|
5
24
|
maxDays: number;
|
|
25
|
+
/** If true, do not output log messages to stdout */
|
|
6
26
|
noStdout: boolean;
|
|
27
|
+
/** Use local time instead of UTC for the log timestamps */
|
|
7
28
|
localTime?: string;
|
|
29
|
+
/** Colorize the console output */
|
|
8
30
|
colorize?: boolean;
|
|
31
|
+
/** Output log entries in JSON format */
|
|
9
32
|
json?: boolean;
|
|
33
|
+
/** Label prepended to every log message */
|
|
10
34
|
prefix?: string;
|
|
35
|
+
/** Winston transport configurations keyed by transport name */
|
|
11
36
|
transport: Record<string, any>;
|
|
12
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Create and configure a winston logger instance for the controller and adapters
|
|
40
|
+
*
|
|
41
|
+
* @param level Log level as a string, or a full UserOptions object with the detailed configuration
|
|
42
|
+
* @param files One or more log file paths the logger should write to
|
|
43
|
+
* @param noStdout If true, do not output log messages to stdout
|
|
44
|
+
* @param prefix Label prepended to every log message
|
|
45
|
+
*/
|
|
13
46
|
export declare function logger(level: string | UserOptions, files?: string[] | string, noStdout?: boolean, prefix?: string): winston.Logger;
|
|
14
47
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name in all)
|
|
10
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -32,17 +33,17 @@ __export(logger_exports, {
|
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(logger_exports);
|
|
34
35
|
var __import_meta_url = typeof document === "undefined" ? new (require("url".replace("", ""))).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
35
|
-
var import_winston = __toESM(require("winston"), 1);
|
|
36
|
-
var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"), 1);
|
|
37
36
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
38
37
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
39
38
|
var import_node_os = __toESM(require("node:os"), 1);
|
|
40
|
-
var
|
|
39
|
+
var url = __toESM(require("node:url"), 1);
|
|
40
|
+
var import_node_module = require("node:module");
|
|
41
|
+
var import_winston = __toESM(require("winston"), 1);
|
|
42
|
+
var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"), 1);
|
|
41
43
|
var import_winston_transport = __toESM(require("winston-transport"), 1);
|
|
42
44
|
var import_triple_beam = require("triple-beam");
|
|
43
45
|
var import_deep_clone = __toESM(require("deep-clone"), 1);
|
|
44
|
-
var
|
|
45
|
-
var import_node_module = require("node:module");
|
|
46
|
+
var tools = __toESM(require("../../lib/common/tools.js"), 1);
|
|
46
47
|
const thisDir = url.fileURLToPath(new URL(".", __import_meta_url || `file://${__filename}`));
|
|
47
48
|
const require2 = (0, import_node_module.createRequire)(__import_meta_url || `file://${__filename}`);
|
|
48
49
|
const hostname = tools.getHostName();
|
|
@@ -80,7 +81,7 @@ const IoSysLog = SysLog && class extends SysLog {
|
|
|
80
81
|
const IoSeq = Seq && class extends Seq {
|
|
81
82
|
log(info, callback) {
|
|
82
83
|
const ioInfo = (0, import_deep_clone.default)(info);
|
|
83
|
-
ioInfo.props
|
|
84
|
+
ioInfo.props ||= {};
|
|
84
85
|
const level = (ioInfo.level || "").toLowerCase();
|
|
85
86
|
if (level.includes("error")) {
|
|
86
87
|
ioInfo.level = "Error";
|
|
@@ -96,7 +97,7 @@ const IoSeq = Seq && class extends Seq {
|
|
|
96
97
|
ioInfo.level = "Information";
|
|
97
98
|
}
|
|
98
99
|
ioInfo.props.Hostname = tools.getHostName();
|
|
99
|
-
if (ioInfo.message) {
|
|
100
|
+
if (typeof ioInfo.message === "string") {
|
|
100
101
|
const msgParts = ioInfo.message.match(/^([^.]+\.[0-9]+) \(([^)]+)\) (.*)$/s);
|
|
101
102
|
if (msgParts) {
|
|
102
103
|
ioInfo.props.Source = msgParts[1];
|
|
@@ -109,10 +110,16 @@ const IoSeq = Seq && class extends Seq {
|
|
|
109
110
|
}
|
|
110
111
|
};
|
|
111
112
|
class NotifierTransport extends import_winston_transport.default {
|
|
112
|
-
|
|
113
|
+
static {
|
|
114
|
+
__name(this, "NotifierTransport");
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Name used by controller and adapters to locate this transport via
|
|
118
|
+
* `logger.transports.find(t => t.name === 'NT')`. Must stay 'NT'.
|
|
119
|
+
*/
|
|
120
|
+
name = "NT";
|
|
113
121
|
constructor(opts) {
|
|
114
122
|
super(opts);
|
|
115
|
-
this.name = "NT";
|
|
116
123
|
}
|
|
117
124
|
log(info, callback) {
|
|
118
125
|
const msg = {
|
|
@@ -131,8 +138,8 @@ function logger(level, files, noStdout, prefix) {
|
|
|
131
138
|
if (typeof files === "string") {
|
|
132
139
|
files = [files];
|
|
133
140
|
}
|
|
134
|
-
const formatter = (info) => `${timestamp(info.timestamp)} - ${info.level}: ${info.message}
|
|
135
|
-
files
|
|
141
|
+
const formatter = /* @__PURE__ */ __name((info) => `${timestamp(info.timestamp)} - ${info.level}: ${info.message}`, "formatter");
|
|
142
|
+
files ||= [];
|
|
136
143
|
const isNpm = !thisDir.replace(/\\/g, "/").toLowerCase().includes(`${tools.appName.toLowerCase()}.js-controller/packages/`);
|
|
137
144
|
if (tools.isObject(level)) {
|
|
138
145
|
const userOptions = (0, import_deep_clone.default)(level);
|
|
@@ -159,10 +166,10 @@ function logger(level, files, noStdout, prefix) {
|
|
|
159
166
|
const isWindows = import_node_os.default.platform().startsWith("win");
|
|
160
167
|
for (const transport of Object.values(userOptions.transport)) {
|
|
161
168
|
transport._defaultConfigLoglevel = transport.level;
|
|
162
|
-
transport.level
|
|
169
|
+
transport.level ||= level;
|
|
163
170
|
if (transport.type === "file" && transport.enabled !== false) {
|
|
164
|
-
transport.filename
|
|
165
|
-
if (!transport.fileext && transport.filename.
|
|
171
|
+
transport.filename ||= `log/${tools.appName}`;
|
|
172
|
+
if (!transport.fileext && !transport.filename.endsWith(".log")) {
|
|
166
173
|
transport.fileext = ".log";
|
|
167
174
|
}
|
|
168
175
|
if (!fName) {
|
|
@@ -178,11 +185,11 @@ function logger(level, files, noStdout, prefix) {
|
|
|
178
185
|
transport.filename = import_node_path.default.normalize(`${tools.getControllerDir()}${isNpm ? "/../../" : "/"}${transport.filename}`);
|
|
179
186
|
}
|
|
180
187
|
transport.auditFile = `${transport.filename}-audit.json`;
|
|
181
|
-
transport.createSymlink
|
|
182
|
-
transport.symlinkName
|
|
188
|
+
transport.createSymlink ??= !isWindows;
|
|
189
|
+
transport.symlinkName ??= import_node_path.default.basename(`${transport.filename}.current.log`);
|
|
183
190
|
transport.filename += `.%DATE%${transport.fileext || ""}`;
|
|
184
191
|
transport.silent = transport.silent !== void 0 ? transport.silent : false;
|
|
185
|
-
transport.localTime
|
|
192
|
+
transport.localTime ??= userOptions.localTime ?? true;
|
|
186
193
|
transport.datePattern = "YYYY-MM-DD";
|
|
187
194
|
transport.format = import_winston.default.format.combine(import_winston.default.format.printf(formatter));
|
|
188
195
|
transport.zippedArchive = isWindows ? false : transport.zippedArchive !== void 0 ? transport.zippedArchive : true;
|
|
@@ -191,9 +198,7 @@ function logger(level, files, noStdout, prefix) {
|
|
|
191
198
|
}
|
|
192
199
|
try {
|
|
193
200
|
const _log = new import_winston_daily_rotate_file.default(transport);
|
|
194
|
-
_log.on("error", (err) => {
|
|
195
|
-
console.error(`Error on log file rotation: ${err.message}`);
|
|
196
|
-
});
|
|
201
|
+
_log.on("error", (err) => console.error(`Error on log file rotation: ${err.message}`));
|
|
197
202
|
options.transports.push(_log);
|
|
198
203
|
} catch (e) {
|
|
199
204
|
if (e.code === "EACCES") {
|
|
@@ -206,7 +211,7 @@ function logger(level, files, noStdout, prefix) {
|
|
|
206
211
|
console.error("Syslog configured, but not installed! Ignore");
|
|
207
212
|
continue;
|
|
208
213
|
}
|
|
209
|
-
transport.localhost
|
|
214
|
+
transport.localhost ||= hostname;
|
|
210
215
|
transport.format = import_winston.default.format.combine(import_winston.default.format.printf(formatter));
|
|
211
216
|
if (transport.sysLogType) {
|
|
212
217
|
transport.type = transport.sysLogType;
|
|
@@ -220,14 +225,14 @@ function logger(level, files, noStdout, prefix) {
|
|
|
220
225
|
console.error(`Cannot activate Syslog: ${e.message}`);
|
|
221
226
|
}
|
|
222
227
|
} else if (transport.type === "http" && transport.enabled !== false) {
|
|
223
|
-
transport.host
|
|
228
|
+
transport.host ||= "localhost";
|
|
224
229
|
try {
|
|
225
230
|
options.transports.push(new import_winston.default.transports.Http(transport));
|
|
226
231
|
} catch (e) {
|
|
227
232
|
console.error(`Cannot activate HTTP: ${e.message}`);
|
|
228
233
|
}
|
|
229
234
|
} else if (transport.type === "stream" && transport.enabled !== false) {
|
|
230
|
-
transport.host
|
|
235
|
+
transport.host ||= "localhost";
|
|
231
236
|
try {
|
|
232
237
|
if (typeof transport.stream === "string") {
|
|
233
238
|
transport.stream = import_node_fs.default.createWriteStream(transport.stream);
|
|
@@ -246,9 +251,7 @@ function logger(level, files, noStdout, prefix) {
|
|
|
246
251
|
}
|
|
247
252
|
if (transport.serverUrl) {
|
|
248
253
|
try {
|
|
249
|
-
transport.onError = (e) => {
|
|
250
|
-
console.log(`SEQ error: ${e.message}`);
|
|
251
|
-
};
|
|
254
|
+
transport.onError = (e) => console.log(`SEQ error: ${e.message}`);
|
|
252
255
|
const seqLogger = new IoSeq(transport);
|
|
253
256
|
options.transports.push(seqLogger);
|
|
254
257
|
} catch (e) {
|
|
@@ -284,10 +287,8 @@ function logger(level, files, noStdout, prefix) {
|
|
|
284
287
|
options.transports.push(new import_winston.default.transports.Console({
|
|
285
288
|
level,
|
|
286
289
|
silent: false,
|
|
290
|
+
// @ts-expect-error fix later
|
|
287
291
|
format: import_winston.default.format.combine(import_winston.default.format.printf(formatter))
|
|
288
|
-
//colorize: (userOptions.colorize === undefined) ? true : userOptions.colorize, // TODO format.colorize()
|
|
289
|
-
//timestamp: timestamp, // TODO: format.timestamp()
|
|
290
|
-
//label: prefix || '' // TODO format.label()
|
|
291
292
|
}));
|
|
292
293
|
}
|
|
293
294
|
options.transports.push(new NotifierTransport({
|
|
@@ -296,23 +297,19 @@ function logger(level, files, noStdout, prefix) {
|
|
|
296
297
|
}));
|
|
297
298
|
const log = import_winston.default.createLogger(options);
|
|
298
299
|
log.getFileName = function() {
|
|
299
|
-
let transport = this.transports.find((t) => t.transport
|
|
300
|
+
let transport = this.transports.find((t) => t.transport?.dirname || t.dirname);
|
|
300
301
|
if (transport) {
|
|
301
|
-
transport = transport.transport
|
|
302
|
+
transport = transport.transport || transport;
|
|
302
303
|
return `${transport.dirname}/${transport.filename.replace("%DATE%", getDate())}`;
|
|
303
304
|
}
|
|
304
305
|
return "";
|
|
305
306
|
};
|
|
306
|
-
log.on("error", (error) => {
|
|
307
|
-
console.log(`Logger error: ${error.message}`);
|
|
308
|
-
});
|
|
307
|
+
log.on("error", (error) => console.log(`Logger error: ${error.message}`));
|
|
309
308
|
log.activateDateChecker = function(isEnabled, daysCount) {
|
|
310
309
|
if (!isEnabled && this._fileChecker) {
|
|
311
310
|
clearInterval(this._fileChecker);
|
|
312
311
|
} else if (isEnabled && !this._fileChecker) {
|
|
313
|
-
|
|
314
|
-
daysCount = 3;
|
|
315
|
-
}
|
|
312
|
+
daysCount ||= 3;
|
|
316
313
|
this._fileChecker = setInterval(() => {
|
|
317
314
|
this.transports.forEach((transport) => {
|
|
318
315
|
if (
|
|
@@ -368,14 +365,17 @@ function logger(level, files, noStdout, prefix) {
|
|
|
368
365
|
};
|
|
369
366
|
return log;
|
|
370
367
|
}
|
|
368
|
+
__name(logger, "logger");
|
|
371
369
|
function getDate() {
|
|
372
370
|
const ts = /* @__PURE__ */ new Date();
|
|
373
371
|
return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, "0")}-${ts.getDate().toString().padStart(2, "0")}`;
|
|
374
372
|
}
|
|
373
|
+
__name(getDate, "getDate");
|
|
375
374
|
function timestamp(date) {
|
|
376
375
|
const ts = date ? new Date(date) : /* @__PURE__ */ new Date();
|
|
377
376
|
return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, "0")}-${ts.getDate().toString().padStart(2, "0")} ${ts.getHours().toString().padStart(2, "0")}:${ts.getMinutes().toString().padStart(2, "0")}:${ts.getSeconds().toString().padStart(2, "0")}.${ts.getMilliseconds().toString().padStart(3, "0")} `;
|
|
378
377
|
}
|
|
378
|
+
__name(timestamp, "timestamp");
|
|
379
379
|
// Annotate the CommonJS export names for ESM import in node:
|
|
380
380
|
0 && (module.exports = {
|
|
381
381
|
logger
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/common/logger.ts", "../../../../../../node_modules/@alcalzone/esm2cjs/shims/import.meta.url/shim.js"],
|
|
4
|
-
"sourcesContent": ["import winston from 'winston';\nimport DailyRotateFile from 'winston-daily-rotate-file';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\nimport * as tools from '@/lib/common/tools.js';\nimport Transport from 'winston-transport';\nimport { LEVEL } from 'triple-beam';\nimport deepClone from 'deep-clone';\nimport type { Syslog } from 'winston-syslog';\nimport type { SeqTransport } from '@datalust/winston-seq';\nimport * as url from 'node:url';\nimport { createRequire } from 'node:module';\n\n// eslint-disable-next-line unicorn/prefer-module\nconst thisDir = url.fileURLToPath(new URL('.', import.meta.url || `file://${__filename}`));\n\n// eslint-disable-next-line unicorn/prefer-module\nconst require = createRequire(import.meta.url || `file://${__filename}`);\n\nconst hostname = tools.getHostName();\n\nlet SysLog: typeof Syslog | undefined;\ntry {\n SysLog = require('winston-syslog').Syslog;\n} catch {\n //console.log('No syslog support');\n}\n\nlet Seq: typeof SeqTransport | undefined;\ntry {\n Seq = require('@datalust/winston-seq').SeqTransport;\n} catch {\n //console.log('No seq support');\n}\n\nexport type LogInfo = Record<string | symbol, any>;\n\n// We must check if SysLog is defined before extending it\nconst IoSysLog =\n SysLog &&\n class extends SysLog {\n constructor(options: any) {\n super(options);\n }\n log(info: LogInfo, callback: () => void): void {\n // we need to map the ioBroker loglevels to the Syslog ones\n const ioInfo = info;\n if (ioInfo[LEVEL] === 'warn') {\n ioInfo[LEVEL] = 'warning';\n }\n if (ioInfo[LEVEL] === 'info') {\n ioInfo[LEVEL] = 'notice';\n }\n if (ioInfo[LEVEL] === 'debug') {\n ioInfo[LEVEL] = 'info';\n }\n if (ioInfo[LEVEL] === 'silly') {\n ioInfo[LEVEL] = 'debug';\n }\n\n // No clue why log could ever be undefined, but hey...\n super.log?.(ioInfo, callback);\n }\n };\n\n// We want to enhance some data for Seq\nconst IoSeq =\n Seq &&\n class extends Seq {\n log(info: LogInfo, callback: () => void): void {\n const ioInfo = deepClone(info);\n ioInfo.props = ioInfo.props || {};\n\n // map our log levels to Seq levels\n const level = (ioInfo.level || '').toLowerCase();\n if (level.includes('error')) {\n ioInfo.level = 'Error';\n } else if (level.includes('warn')) {\n ioInfo.level = 'Warning';\n } else if (level.includes('info')) {\n ioInfo.level = 'Information';\n } else if (level.includes('debug')) {\n ioInfo.level = 'Debug';\n } else if (level.includes('silly')) {\n ioInfo.level = 'Verbose';\n } else {\n ioInfo.level = 'Information';\n }\n\n // we add own properties\n ioInfo.props.Hostname = tools.getHostName();\n if (ioInfo.message) {\n // handle as single line with s flag, to if message ends with CR, etc\n const msgParts = ioInfo.message.match(/^([^.]+\\.[0-9]+) \\(([^)]+)\\) (.*)$/s);\n if (msgParts) {\n ioInfo.props.Source = msgParts[1];\n ioInfo.props.Pid = msgParts[2];\n } else {\n ioInfo.props.Source = 'js-controller';\n }\n }\n super.log(ioInfo, callback);\n }\n };\n\n// Class used to inform adapter about new log entry\nclass NotifierTransport extends Transport {\n private name: string;\n constructor(opts: any) {\n super(opts);\n this.name = 'NT'; // NotifierTransport\n }\n\n log(info: LogInfo, callback: () => void): void {\n const msg = {\n severity: info[LEVEL],\n ts: new Date(info.timestamp).getTime(),\n message: info.message,\n };\n setImmediate(() => this.emit('logged', msg));\n callback();\n }\n}\n\nexport interface UserOptions {\n level: string;\n maxDays: number;\n noStdout: boolean;\n localTime?: string;\n colorize?: boolean;\n json?: boolean;\n prefix?: string;\n transport: Record<string, any>;\n}\n\ninterface Options {\n format?: winston.Logform.Format;\n transports: Transport[];\n}\n\nexport function logger(\n level: string | UserOptions,\n files?: string[] | string,\n noStdout?: boolean,\n prefix?: string,\n): winston.Logger {\n const options: Options = {\n transports: [],\n };\n\n //var defaultMaxSize;// = 10 * 1024 * 1024;\n\n if (typeof files === 'string') {\n files = [files];\n }\n\n const formatter = (info: LogInfo): string => `${timestamp(info.timestamp)} - ${info.level}: ${info.message}`;\n\n files = files || [];\n\n // indicator which is used to determine the log dir for developing, where it should be inside the repository\n const isNpm = !thisDir\n .replace(/\\\\/g, '/')\n .toLowerCase()\n .includes(`${tools.appName.toLowerCase()}.js-controller/packages/`);\n\n if (tools.isObject(level)) {\n const userOptions: UserOptions = deepClone(level);\n\n level = userOptions.level;\n prefix = userOptions.prefix || '';\n noStdout = userOptions.noStdout;\n const winstonFormats = [];\n // @ts-expect-error formatter arg wrongly documented\n winstonFormats.push(winston.format.timestamp({ format: timestamp }));\n if (userOptions.json === undefined || userOptions.json) {\n winstonFormats.push(winston.format.json());\n }\n if (prefix) {\n winstonFormats.push(winston.format.label({ label: prefix }));\n }\n if (userOptions.colorize === undefined || userOptions.colorize) {\n winstonFormats.push(winston.format.colorize());\n }\n options.format = winston.format.combine.apply(null, winstonFormats);\n\n if (userOptions.prefix !== undefined) {\n delete userOptions.prefix;\n }\n\n if (userOptions.transport) {\n let fName = 0;\n const isWindows = os.platform().startsWith('win');\n for (const transport of Object.values(userOptions.transport)) {\n transport._defaultConfigLoglevel = transport.level; // remember Loglevel if set\n transport.level = transport.level || level;\n\n if (transport.type === 'file' && transport.enabled !== false) {\n transport.filename = transport.filename || `log/${tools.appName}`;\n\n if (!transport.fileext && transport.filename.indexOf('.log') === -1) {\n transport.fileext = '.log';\n }\n\n if (!fName) {\n transport.systemLog = true;\n }\n\n transport.handleExceptions = false;\n transport.name = fName ? `dailyRotateFile${fName}` : tools.appName;\n fName++;\n transport.filename = transport.filename.replace(/\\\\/g, '/');\n if (transport.filename.match(/^\\w:\\/|^\\//)) {\n transport.filename = path.normalize(transport.filename);\n } else {\n transport.filename = path.normalize(\n `${tools.getControllerDir()}${isNpm ? '/../../' : '/'}${transport.filename}`,\n );\n }\n transport.auditFile = `${transport.filename}-audit.json`;\n\n transport.createSymlink =\n transport.createSymlink !== undefined ? transport.createSymlink : !isWindows;\n transport.symlinkName =\n transport.symlinkName !== undefined\n ? transport.symlinkName\n : path.basename(`${transport.filename}.current.log`);\n\n transport.filename += `.%DATE%${transport.fileext || ''}`;\n //transport.label = prefix || ''; //TODO format.label()\n // transport.json = (transport.json !== undefined) ? transport.json : false; // TODO format.json(), new Default!!\n transport.silent = transport.silent !== undefined ? transport.silent : false;\n // transport.colorize = (transport.colorize !== undefined) ? transport.colorize : ((userOptions.colorize === undefined) ? true : userOptions.colorize); //TODO format.colorize()\n transport.localTime =\n transport.localTime !== undefined\n ? transport.localTime\n : userOptions.localTime === undefined\n ? true\n : userOptions.localTime;\n transport.datePattern = 'YYYY-MM-DD';\n transport.format = winston.format.combine(winston.format.printf(formatter));\n /*transport.logException = function (message, info, next, err) {\n console.error(message);\n };*/\n transport.zippedArchive = isWindows\n ? false\n : transport.zippedArchive !== undefined\n ? transport.zippedArchive\n : true;\n\n if (transport.maxFiles === null && userOptions.maxDays) {\n transport.maxFiles = `${userOptions.maxDays}d`;\n }\n\n try {\n const _log = new DailyRotateFile(transport);\n\n _log.on('error', err => {\n console.error(`Error on log file rotation: ${err.message}`);\n });\n\n options.transports.push(_log);\n } catch (e) {\n if (e.code === 'EACCES') {\n // modify error code to make it unique for handling\n e.code = 'EACCES_LOG';\n }\n throw e;\n }\n } else if (transport.type === 'syslog' && transport.enabled !== false) {\n if (!IoSysLog) {\n console.error('Syslog configured, but not installed! Ignore');\n continue;\n }\n // host: The host running syslogd, defaults to localhost.\n // port: The port on the host that syslog is running on, defaults to syslogd's default port.\n // protocol: The network protocol to log over (e.g. tcp4, udp4, unix, unix-connect, etc).\n // path: The path to the syslog dgram socket (i.e. /dev/log or /var/run/syslog for OS X).\n // pid: PID of the process that log messages are coming from (Default process.pid).\n // facility: Syslog facility to use (Default: local0).\n // localhost: Host to indicate that log messages are coming from (Default: localhost).\n // sysLogType: The type of the syslog protocol to use (Default: BSD).\n // app_name: The name of the application (Default: process.title).\n // eol: The end of line character to be added to the end of the message (Default: Message without modifications).\n // replace the used by syslog attribute \"type\" with own \"sysLogType\"\n\n // If no name defined, use hostname as name\n transport.localhost = transport.localhost || hostname;\n transport.format = winston.format.combine(winston.format.printf(formatter));\n if (transport.sysLogType) {\n transport.type = transport.sysLogType;\n delete transport.sysLogType;\n } else {\n delete transport.type;\n }\n try {\n options.transports.push(new IoSysLog(transport));\n } catch (e) {\n console.error(`Cannot activate Syslog: ${e.message}`);\n }\n } else if (transport.type === 'http' && transport.enabled !== false) {\n // host: (Default: localhost) Remote host of the HTTP logging endpoint\n // port: (Default: 80 or 443) Remote port of the HTTP logging endpoint\n // path: (Default: /) Remote URI of the HTTP logging endpoint\n // auth: (Default: None) An object representing the username and password for HTTP Basic Auth\n // ssl: (Default: false) Value indicating if we should use HTTPS\n\n // If no name defined, use hostname as name\n transport.host = transport.host || 'localhost';\n\n try {\n options.transports.push(new winston.transports.Http(transport));\n } catch (e) {\n console.error(`Cannot activate HTTP: ${e.message}`);\n }\n } else if (transport.type === 'stream' && transport.enabled !== false) {\n // stream: any Node.js stream. If an objectMode stream is provided then the entire info object will be written. Otherwise info[MESSAGE] will be written.\n // level: Level of messages that this transport should log (default: level set on parent logger).\n // silent: Boolean flag indicating whether to suppress output (default false).\n // eol: Line-ending character to use. (default: os.EOL).\n\n // If no name defined, use hostname as name\n transport.host = transport.host || 'localhost';\n\n try {\n if (typeof transport.stream === 'string') {\n transport.stream = fs.createWriteStream(transport.stream);\n transport.stream.on('error', (err: Error) => {\n console.error(`Error in Stream: ${err.message}`);\n });\n }\n\n options.transports.push(new winston.transports.Stream(transport));\n } catch (e) {\n console.error(`Cannot activate Stream: ${e.message}`);\n }\n } else if (transport.type === 'seq' && transport.enabled !== false) {\n if (!IoSeq) {\n console.error('Seq configured, but not installed! Ignore');\n continue;\n }\n // serverUrl?: string;\n // apiKey?: string;\n // maxBatchingTime?: number;\n // eventSizeLimit?: number;\n // batchSizeLimit?: number;\n\n // Add only if serverUrl is configured at least\n if (transport.serverUrl) {\n try {\n transport.onError = (e: Error) => {\n console.log(`SEQ error: ${e.message}`);\n };\n const seqLogger = new IoSeq(transport);\n options.transports.push(seqLogger);\n } catch (e) {\n console.error(`Cannot activate SEQ: ${e.message}`);\n }\n } else {\n console.error('Cannot activate SEQ: No serverUrl specified');\n }\n }\n }\n }\n } else {\n for (let i = 0; i < files.length; i++) {\n const opt = {\n name: i ? `dailyRotateFile${i}` : tools.appName,\n filename: path.normalize(\n isNpm ? `${thisDir}/../../../log/${files[i]}` : `${thisDir}/../log/${files[i]}`,\n ),\n extension: '.log',\n datePattern: 'YYYY-MM-DD',\n //json: false, // If true, messages will be logged as JSON (default true). TODO format.json()\n level,\n silent: false,\n localTime: true,\n //colorize: (userOptions.colorize === undefined) ? true : userOptions.colorize, // TODO format.colorize()\n //timestamp: timestamp, // TODO: format.timestamp()\n //label: prefix || '', // TODO format.label()\n handleExceptions: false,\n //maxSize: defaultMaxSize\n };\n\n options.transports.push(new DailyRotateFile(opt));\n }\n }\n\n if (!noStdout) {\n options.transports.push(\n new winston.transports.Console({\n level,\n silent: false,\n format: winston.format.combine(winston.format.printf(formatter)),\n //colorize: (userOptions.colorize === undefined) ? true : userOptions.colorize, // TODO format.colorize()\n //timestamp: timestamp, // TODO: format.timestamp()\n //label: prefix || '' // TODO format.label()\n }),\n );\n }\n\n // Must be registered, for adapter.js notification about new logs\n options.transports.push(\n new NotifierTransport({\n level,\n silent: false,\n }),\n );\n\n const log = winston.createLogger(options);\n\n // @ts-expect-error why do we override/add method to foreign instance? TODO\n log.getFileName = function () {\n // @ts-expect-error we use undocumented stuff here TODO\n let transport = this.transports.find(t => (t.transport && t.transport.dirname) || t.dirname);\n if (transport) {\n // @ts-expect-error we use undocumented stuff here TODO\n transport = transport.transport ? transport.transport : transport;\n // @ts-expect-error we use undocumented stuff here TODO\n return `${transport.dirname}/${transport.filename.replace('%DATE%', getDate())}`;\n }\n return '';\n };\n\n log.on('error', error => {\n console.log(`Logger error: ${error.message}`);\n });\n\n // This cannot be deleted, because file rotate works with the size of files and not with the time\n // TODO research and open new issue in winston-daily-rotate-file repo\n /**\n * @param isEnabled\n * @param daysCount\n */\n // @ts-expect-error why do we override/add method to foreign instance? TODO\n log.activateDateChecker = function (isEnabled, daysCount) {\n // @ts-expect-error we use undocumented stuff here TODO\n if (!isEnabled && this._fileChecker) {\n // @ts-expect-error we use undocumented stuff here TODO\n clearInterval(this._fileChecker);\n // @ts-expect-error we use undocumented stuff here TODO\n } else if (isEnabled && !this._fileChecker) {\n if (!daysCount) {\n daysCount = 3;\n }\n\n // Check every hour\n // @ts-expect-error we use undocumented stuff here TODO\n this._fileChecker = setInterval(() => {\n this.transports.forEach(transport => {\n if (\n // @ts-expect-error we use undocumented stuff here TODO\n transport.name !== 'dailyRotateFile' ||\n // @ts-expect-error we use undocumented stuff here TODO\n !transport.options ||\n // @ts-expect-error we use undocumented stuff here TODO\n transport.options.name !== tools.appName\n ) {\n return;\n }\n\n // @ts-expect-error we use undocumented stuff here TODO\n if (transport && fs.existsSync(transport.dirname)) {\n let files;\n try {\n // @ts-expect-error we use undocumented stuff here TODO\n files = fs.readdirSync(transport.dirname);\n } catch (e) {\n console.error(`host.${hostname} Cannot read log directory: ${e.message}`);\n return;\n }\n const forXdays = new Date();\n forXdays.setDate(forXdays.getDate() - daysCount - 1); // normally winston now takes care, for old or on errors make sure fallback works a day later\n\n for (let i = 0; i < files.length; i++) {\n const match = files[i].match(/.+\\.(\\d+-\\d+-\\d+)/);\n if (match) {\n const date = new Date(match[1]);\n if (date < forXdays) {\n // delete file\n try {\n this.log({\n level: 'info',\n message: `host.${hostname} Delete log file ${files[i]}`,\n });\n console.log(`host.${hostname} Delete log file ${files[i]}`);\n // @ts-expect-error we use undocumented stuff here TODO\n fs.unlinkSync(`${transport.dirname}/${files[i]}`);\n } catch (e) {\n // there is a bug under windows, that file stays opened and cannot be deleted\n this.log({\n level: os.platform().startsWith('win') ? 'info' : 'error',\n message: `host.${hostname} Cannot delete file \"${path.normalize(\n // @ts-expect-error we use undocumented stuff here TODO\n `${transport.dirname}/${files[i]}`,\n )}\": ${e}`,\n });\n console.log(\n `host.${hostname} Cannot delete file \"${path.normalize(\n // @ts-expect-error we use undocumented stuff here TODO\n `${transport.dirname}/${files[i]}`,\n )}\": ${e.message}`,\n );\n }\n }\n }\n }\n }\n });\n }, 3_600_000); // every hour\n }\n };\n\n return log;\n}\n\nfunction getDate(): string {\n const ts = new Date();\n return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, '0')}-${ts\n .getDate()\n .toString()\n .padStart(2, '0')}`;\n}\n\nfunction timestamp(date: string): string {\n const ts = date ? new Date(date) : new Date();\n return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, '0')}-${ts\n .getDate()\n .toString()\n .padStart(2, '0')} ${ts.getHours().toString().padStart(2, '0')}:${ts\n .getMinutes()\n .toString()\n .padStart(2, '0')}:${ts.getSeconds().toString().padStart(2, '0')}.${ts\n .getMilliseconds()\n .toString()\n .padStart(3, '0')} `;\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\nimport * as url from 'node:url';\nimport { createRequire } from 'node:module';\n\nimport winston from 'winston';\nimport DailyRotateFile from 'winston-daily-rotate-file';\nimport Transport, { type TransportStreamOptions } from 'winston-transport';\nimport type { SeqTransport } from '@datalust/winston-seq';\nimport type { Syslog, SyslogTransportOptions } from 'winston-syslog';\nimport { LEVEL } from 'triple-beam';\nimport deepClone from 'deep-clone';\n\nimport * as tools from '@/lib/common/tools.js';\nimport type { TransformableInfo } from 'logform';\n\n// eslint-disable-next-line unicorn/prefer-module\nconst thisDir = url.fileURLToPath(new URL('.', import.meta.url || `file://${__filename}`));\n\n// eslint-disable-next-line unicorn/prefer-module\nconst require = createRequire(import.meta.url || `file://${__filename}`);\n\nconst hostname = tools.getHostName();\n\nlet SysLog: typeof Syslog | undefined;\ntry {\n SysLog = require('winston-syslog').Syslog;\n} catch {\n //console.log('No syslog support');\n}\n\nlet Seq: typeof SeqTransport | undefined;\ntry {\n Seq = require('@datalust/winston-seq').SeqTransport;\n} catch {\n //console.log('No seq support');\n}\n\n/** Log entry enriched with ioBroker specific properties */\nexport interface LogInfo extends TransformableInfo {\n /** The log message text */\n message: string;\n /** Additional properties attached to the log entry */\n props?: {\n /** The host the log entry originates from */\n Hostname?: string;\n /** The source (adapter/instance) of the log entry */\n Source?: string;\n /** The process id that produced the log entry */\n Pid?: string;\n };\n /** ISO timestamp of the log entry */\n timestamp: string;\n}\n\n// We must check if SysLog is defined before extending it\nconst IoSysLog =\n SysLog &&\n class extends SysLog {\n constructor(options?: SyslogTransportOptions) {\n super(options);\n }\n log(info: LogInfo, callback: () => void): void {\n // we need to map the ioBroker loglevels to the Syslog ones\n const ioInfo = info;\n if (ioInfo[LEVEL] === 'warn') {\n ioInfo[LEVEL] = 'warning';\n }\n if (ioInfo[LEVEL] === 'info') {\n ioInfo[LEVEL] = 'notice';\n }\n if (ioInfo[LEVEL] === 'debug') {\n ioInfo[LEVEL] = 'info';\n }\n if (ioInfo[LEVEL] === 'silly') {\n ioInfo[LEVEL] = 'debug';\n }\n\n // No clue why log could ever be undefined, but hey...\n super.log?.(ioInfo, callback);\n }\n };\n\n// We want to enhance some data for Seq\nconst IoSeq =\n Seq &&\n class extends Seq {\n log(info: LogInfo, callback: () => void): void {\n const ioInfo = deepClone(info);\n ioInfo.props ||= {};\n\n // map our log levels to Seq levels\n const level = (ioInfo.level || '').toLowerCase();\n if (level.includes('error')) {\n ioInfo.level = 'Error';\n } else if (level.includes('warn')) {\n ioInfo.level = 'Warning';\n } else if (level.includes('info')) {\n ioInfo.level = 'Information';\n } else if (level.includes('debug')) {\n ioInfo.level = 'Debug';\n } else if (level.includes('silly')) {\n ioInfo.level = 'Verbose';\n } else {\n ioInfo.level = 'Information';\n }\n\n // we add own properties\n ioInfo.props.Hostname = tools.getHostName();\n if (typeof ioInfo.message === 'string') {\n // handle as single line with s flag, to if message ends with CR, etc\n const msgParts = ioInfo.message.match(/^([^.]+\\.[0-9]+) \\(([^)]+)\\) (.*)$/s);\n if (msgParts) {\n ioInfo.props.Source = msgParts[1];\n ioInfo.props.Pid = msgParts[2];\n } else {\n ioInfo.props.Source = 'js-controller';\n }\n }\n super.log(ioInfo, callback);\n }\n };\n\n// Class used to inform adapter about new log entry\nclass NotifierTransport extends Transport {\n /**\n * Name used by controller and adapters to locate this transport via\n * `logger.transports.find(t => t.name === 'NT')`. Must stay 'NT'.\n */\n public readonly name = 'NT';\n\n constructor(opts?: TransportStreamOptions) {\n super(opts);\n }\n\n log(info: LogInfo, callback: () => void): void {\n const msg = {\n severity: info[LEVEL],\n ts: new Date(info.timestamp).getTime(),\n message: info.message,\n };\n setImmediate(() => this.emit('logged', msg));\n callback();\n }\n}\n\n/** Logger configuration options provided by the user */\nexport interface UserOptions {\n /** Minimum log level to output (e.g. silly, debug, info, warn, error) */\n level: string;\n /** Maximum number of days rotated log files are kept before deletion */\n maxDays: number;\n /** If true, do not output log messages to stdout */\n noStdout: boolean;\n /** Use local time instead of UTC for the log timestamps */\n localTime?: string;\n /** Colorize the console output */\n colorize?: boolean;\n /** Output log entries in JSON format */\n json?: boolean;\n /** Label prepended to every log message */\n prefix?: string;\n /** Winston transport configurations keyed by transport name */\n transport: Record<string, any>;\n}\n\ninterface Options {\n format?: winston.Logform.Format;\n transports: Transport[];\n}\n\n/**\n * Create and configure a winston logger instance for the controller and adapters\n *\n * @param level Log level as a string, or a full UserOptions object with the detailed configuration\n * @param files One or more log file paths the logger should write to\n * @param noStdout If true, do not output log messages to stdout\n * @param prefix Label prepended to every log message\n */\nexport function logger(\n level: string | UserOptions,\n files?: string[] | string,\n noStdout?: boolean,\n prefix?: string,\n): winston.Logger {\n const options: Options = {\n transports: [],\n };\n\n //var defaultMaxSize;// = 10 * 1024 * 1024;\n\n if (typeof files === 'string') {\n files = [files];\n }\n\n const formatter = (info: LogInfo): string => `${timestamp(info.timestamp)} - ${info.level}: ${info.message}`;\n\n files ||= [];\n\n // indicator that is used to determine the log dir for developing, where it should be inside the repository\n const isNpm = !thisDir\n .replace(/\\\\/g, '/')\n .toLowerCase()\n .includes(`${tools.appName.toLowerCase()}.js-controller/packages/`);\n\n if (tools.isObject(level)) {\n const userOptions: UserOptions = deepClone(level);\n\n level = userOptions.level;\n prefix = userOptions.prefix || '';\n noStdout = userOptions.noStdout;\n const winstonFormats = [];\n // @ts-expect-error formatter arg wrongly documented\n winstonFormats.push(winston.format.timestamp({ format: timestamp }));\n if (userOptions.json === undefined || userOptions.json) {\n winstonFormats.push(winston.format.json());\n }\n if (prefix) {\n winstonFormats.push(winston.format.label({ label: prefix }));\n }\n if (userOptions.colorize === undefined || userOptions.colorize) {\n winstonFormats.push(winston.format.colorize());\n }\n options.format = winston.format.combine.apply(null, winstonFormats);\n\n if (userOptions.prefix !== undefined) {\n delete userOptions.prefix;\n }\n\n if (userOptions.transport) {\n let fName = 0;\n const isWindows = os.platform().startsWith('win');\n for (const transport of Object.values(userOptions.transport)) {\n transport._defaultConfigLoglevel = transport.level; // remember Loglevel if set\n transport.level ||= level;\n\n if (transport.type === 'file' && transport.enabled !== false) {\n transport.filename ||= `log/${tools.appName}`;\n\n if (!transport.fileext && !transport.filename.endsWith('.log')) {\n transport.fileext = '.log';\n }\n\n if (!fName) {\n transport.systemLog = true;\n }\n\n transport.handleExceptions = false;\n transport.name = fName ? `dailyRotateFile${fName}` : tools.appName;\n fName++;\n transport.filename = transport.filename.replace(/\\\\/g, '/');\n if (transport.filename.match(/^\\w:\\/|^\\//)) {\n transport.filename = path.normalize(transport.filename);\n } else {\n transport.filename = path.normalize(\n `${tools.getControllerDir()}${isNpm ? '/../../' : '/'}${transport.filename}`,\n );\n }\n transport.auditFile = `${transport.filename}-audit.json`;\n\n transport.createSymlink ??= !isWindows;\n transport.symlinkName ??= path.basename(`${transport.filename}.current.log`);\n\n transport.filename += `.%DATE%${transport.fileext || ''}`;\n //transport.label = prefix || ''; //TODO format.label()\n // transport.json = (transport.json !== undefined) ? transport.json : false; // TODO format.json(), new Default!!\n transport.silent = transport.silent !== undefined ? transport.silent : false;\n // transport.colorize = (transport.colorize !== undefined) ? transport.colorize : ((userOptions.colorize === undefined) ? true : userOptions.colorize); //TODO format.colorize()\n transport.localTime ??= userOptions.localTime ?? true;\n transport.datePattern = 'YYYY-MM-DD';\n // @ts-expect-error fix later\n transport.format = winston.format.combine(winston.format.printf(formatter));\n /*transport.logException = function (message, info, next, err) {\n console.error(message);\n };*/\n transport.zippedArchive = isWindows\n ? false\n : transport.zippedArchive !== undefined\n ? transport.zippedArchive\n : true;\n\n if (transport.maxFiles === null && userOptions.maxDays) {\n transport.maxFiles = `${userOptions.maxDays}d`;\n }\n\n try {\n const _log = new DailyRotateFile(transport);\n\n _log.on('error', err => console.error(`Error on log file rotation: ${err.message}`));\n\n options.transports.push(_log);\n } catch (e) {\n if (e.code === 'EACCES') {\n // modify error code to make it unique for handling\n e.code = 'EACCES_LOG';\n }\n throw e;\n }\n } else if (transport.type === 'syslog' && transport.enabled !== false) {\n if (!IoSysLog) {\n console.error('Syslog configured, but not installed! Ignore');\n continue;\n }\n // host: The host running syslogd, defaults to localhost.\n // port: The port on the host that syslog is running on, defaults to syslogd's default port.\n // protocol: The network protocol to log over (e.g. tcp4, udp4, unix, unix-connect, etc).\n // path: The path to the syslog dgram socket (i.e. /dev/log or /var/run/syslog for OS X).\n // pid: PID of the process that log messages are coming from (Default process.pid).\n // facility: Syslog facility to use (Default: local0).\n // localhost: Host to indicate that log messages are coming from (Default: localhost).\n // sysLogType: The type of the syslog protocol to use (Default: BSD).\n // app_name: The name of the application (Default: process.title).\n // eol: The end of line character to be added to the end of the message (Default: Message without modifications).\n // replace the used by syslog attribute \"type\" with own \"sysLogType\"\n\n // If no name defined, use hostname as name\n transport.localhost ||= hostname;\n // @ts-expect-error fix later\n transport.format = winston.format.combine(winston.format.printf(formatter));\n if (transport.sysLogType) {\n transport.type = transport.sysLogType;\n delete transport.sysLogType;\n } else {\n delete transport.type;\n }\n try {\n options.transports.push(new IoSysLog(transport));\n } catch (e) {\n console.error(`Cannot activate Syslog: ${e.message}`);\n }\n } else if (transport.type === 'http' && transport.enabled !== false) {\n // host: (Default: localhost) Remote host of the HTTP logging endpoint\n // port: (Default: 80 or 443) Remote port of the HTTP logging endpoint\n // path: (Default: /) Remote URI of the HTTP logging endpoint\n // auth: (Default: None) An object representing the username and password for HTTP Basic Auth\n // ssl: (Default: false) Value indicating if we should use HTTPS\n\n // If no name defined, use hostname as name\n transport.host ||= 'localhost';\n\n try {\n options.transports.push(new winston.transports.Http(transport));\n } catch (e) {\n console.error(`Cannot activate HTTP: ${e.message}`);\n }\n } else if (transport.type === 'stream' && transport.enabled !== false) {\n // stream: any Node.js stream. If an objectMode stream is provided then the entire info object will be written. Otherwise, info[MESSAGE] will be written.\n // level: Level of messages that this transport should log (default: level set on parent logger).\n // silent: Boolean flag indicating whether to suppress output (default false).\n // eol: Line-ending character to use. (default: os.EOL).\n\n // If no name defined, use hostname as name\n transport.host ||= 'localhost';\n\n try {\n if (typeof transport.stream === 'string') {\n transport.stream = fs.createWriteStream(transport.stream);\n transport.stream.on('error', (err: Error) => {\n console.error(`Error in Stream: ${err.message}`);\n });\n }\n\n options.transports.push(new winston.transports.Stream(transport));\n } catch (e) {\n console.error(`Cannot activate Stream: ${e.message}`);\n }\n } else if (transport.type === 'seq' && transport.enabled !== false) {\n if (!IoSeq) {\n console.error('Seq configured, but not installed! Ignore');\n continue;\n }\n // serverUrl?: string;\n // apiKey?: string;\n // maxBatchingTime?: number;\n // eventSizeLimit?: number;\n // batchSizeLimit?: number;\n\n // Add only if serverUrl is configured at least\n if (transport.serverUrl) {\n try {\n transport.onError = (e: Error) => console.log(`SEQ error: ${e.message}`);\n const seqLogger = new IoSeq(transport);\n options.transports.push(seqLogger);\n } catch (e) {\n console.error(`Cannot activate SEQ: ${e.message}`);\n }\n } else {\n console.error('Cannot activate SEQ: No serverUrl specified');\n }\n }\n }\n }\n } else {\n for (let i = 0; i < files.length; i++) {\n const opt = {\n name: i ? `dailyRotateFile${i}` : tools.appName,\n filename: path.normalize(\n isNpm ? `${thisDir}/../../../log/${files[i]}` : `${thisDir}/../log/${files[i]}`,\n ),\n extension: '.log',\n datePattern: 'YYYY-MM-DD',\n //json: false, // If true, messages will be logged as JSON (default true). TODO format.json()\n level,\n silent: false,\n localTime: true,\n //colorize: (userOptions.colorize === undefined) ? true : userOptions.colorize, // TODO format.colorize()\n //timestamp: timestamp, // TODO: format.timestamp()\n //label: prefix || '', // TODO format.label()\n handleExceptions: false,\n //maxSize: defaultMaxSize\n };\n\n options.transports.push(new DailyRotateFile(opt));\n }\n }\n\n if (!noStdout) {\n options.transports.push(\n new winston.transports.Console({\n level,\n silent: false,\n // @ts-expect-error fix later\n format: winston.format.combine(winston.format.printf(formatter)),\n }),\n );\n }\n\n // Must be registered, for adapter.js notification about new logs\n options.transports.push(\n new NotifierTransport({\n level,\n silent: false,\n }),\n );\n\n const log = winston.createLogger(options);\n\n // @ts-expect-error why do we override/add method to foreign instance? TODO\n log.getFileName = function () {\n // @ts-expect-error we use undocumented stuff here TODO\n let transport = this.transports.find(t => t.transport?.dirname || t.dirname);\n if (transport) {\n // @ts-expect-error we use undocumented stuff here TODO\n transport = transport.transport || transport;\n // @ts-expect-error we use undocumented stuff here TODO\n return `${transport.dirname}/${transport.filename.replace('%DATE%', getDate())}`;\n }\n return '';\n };\n\n log.on('error', error => console.log(`Logger error: ${error.message}`));\n\n // This cannot be deleted, because file rotate works with the size of files and not with the time\n // TODO research and open new issue in winston-daily-rotate-file repo\n /**\n * Enable or disable the periodic checker that deletes outdated log files\n *\n * @param isEnabled Whether the periodic file checker should run\n * @param daysCount Number of days after which old log files are deleted (defaults to 3)\n */\n // @ts-expect-error why do we override/add method to foreign instance? TODO\n log.activateDateChecker = function (isEnabled, daysCount) {\n // @ts-expect-error we use undocumented stuff here TODO\n if (!isEnabled && this._fileChecker) {\n // @ts-expect-error we use undocumented stuff here TODO\n clearInterval(this._fileChecker);\n // @ts-expect-error we use undocumented stuff here TODO\n } else if (isEnabled && !this._fileChecker) {\n daysCount ||= 3;\n\n // Check every hour\n // @ts-expect-error we use undocumented stuff here TODO\n this._fileChecker = setInterval(() => {\n this.transports.forEach(transport => {\n if (\n // @ts-expect-error we use undocumented stuff here TODO\n transport.name !== 'dailyRotateFile' ||\n // @ts-expect-error we use undocumented stuff here TODO\n !transport.options ||\n // @ts-expect-error we use undocumented stuff here TODO\n transport.options.name !== tools.appName\n ) {\n return;\n }\n\n // @ts-expect-error we use undocumented stuff here TODO\n if (transport && fs.existsSync(transport.dirname)) {\n let files;\n try {\n // @ts-expect-error we use undocumented stuff here TODO\n files = fs.readdirSync(transport.dirname);\n } catch (e) {\n console.error(`host.${hostname} Cannot read log directory: ${e.message}`);\n return;\n }\n const forXdays = new Date();\n forXdays.setDate(forXdays.getDate() - daysCount - 1); // normally winston now takes care, for old or on errors make sure fallback works a day later\n\n for (let i = 0; i < files.length; i++) {\n const match = files[i].match(/.+\\.(\\d+-\\d+-\\d+)/);\n if (match) {\n const date = new Date(match[1]);\n if (date < forXdays) {\n // delete file\n try {\n this.log({\n level: 'info',\n message: `host.${hostname} Delete log file ${files[i]}`,\n });\n console.log(`host.${hostname} Delete log file ${files[i]}`);\n // @ts-expect-error we use undocumented stuff here TODO\n fs.unlinkSync(`${transport.dirname}/${files[i]}`);\n } catch (e) {\n // there is a bug under windows, that file stays opened and cannot be deleted\n this.log({\n level: os.platform().startsWith('win') ? 'info' : 'error',\n message: `host.${hostname} Cannot delete file \"${path.normalize(\n // @ts-expect-error we use undocumented stuff here TODO\n `${transport.dirname}/${files[i]}`,\n )}\": ${e}`,\n });\n console.log(\n `host.${hostname} Cannot delete file \"${path.normalize(\n // @ts-expect-error we use undocumented stuff here TODO\n `${transport.dirname}/${files[i]}`,\n )}\": ${e.message}`,\n );\n }\n }\n }\n }\n }\n });\n }, 3_600_000); // every hour\n }\n };\n\n return log;\n}\n\nfunction getDate(): string {\n const ts = new Date();\n return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, '0')}-${ts\n .getDate()\n .toString()\n .padStart(2, '0')}`;\n}\n\nfunction timestamp(date: string): string {\n const ts = date ? new Date(date) : new Date();\n return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, '0')}-${ts\n .getDate()\n .toString()\n .padStart(2, '0')} ${ts.getHours().toString().padStart(2, '0')}:${ts\n .getMinutes()\n .toString()\n .padStart(2, '0')}:${ts.getSeconds().toString().padStart(2, '0')}.${ts\n .getMilliseconds()\n .toString()\n .padStart(3, '0')} `;\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;ACAO,IAAM,oBACX,OAAO,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,IAAI,EAAE,CAAC,GAAE,IAAK,UAAU,UAAU,EAAE,OAC9F,SAAS,iBAAiB,SAAS,cAAc,OAAO,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;ADFlG,qBAAe;AACf,uBAAiB;AACjB,qBAAe;AACf,UAAqB;AACrB,yBAA8B;AAE9B,qBAAoB;AACpB,uCAA4B;AAC5B,+BAAuD;AAGvD,yBAAsB;AACtB,wBAAsB;AAEtB,YAAuB;AAIvB,MAAM,UAAU,IAAI,cAAc,IAAI,IAAI,KAAK,qBAAmB,UAAU,UAAU,EAAE,CAAC;AAGzF,MAAMA,eAAU,kCAAc,qBAAmB,UAAU,UAAU,EAAE;AAEvE,MAAM,WAAW,MAAM,YAAW;AAElC,IAAI;AACJ,IAAI;AACA,WAASA,SAAQ,gBAAgB,EAAE;AACvC,QAAQ;AAER;AAEA,IAAI;AACJ,IAAI;AACA,QAAMA,SAAQ,uBAAuB,EAAE;AAC3C,QAAQ;AAER;AAoBA,MAAM,WACF,UACA,cAAc,OAAM;EAChB,YAAY,SAAgC;AACxC,UAAM,OAAO;EACjB;EACA,IAAI,MAAe,UAAoB;AAEnC,UAAM,SAAS;AACf,QAAI,OAAO,wBAAK,MAAM,QAAQ;AAC1B,aAAO,wBAAK,IAAI;IACpB;AACA,QAAI,OAAO,wBAAK,MAAM,QAAQ;AAC1B,aAAO,wBAAK,IAAI;IACpB;AACA,QAAI,OAAO,wBAAK,MAAM,SAAS;AAC3B,aAAO,wBAAK,IAAI;IACpB;AAC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G,CAAC;AACzB;AAZS;",
|
|
6
6
|
"names": ["require", "deepClone", "Transport", "winston", "os", "path", "DailyRotateFile", "fs", "files"]
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,6 +32,7 @@ function maybeCallback(callback, ...args) {
|
|
|
31
32
|
return Promise.resolve(args.length > 1 ? args : args[0]);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
35
|
+
__name(maybeCallback, "maybeCallback");
|
|
34
36
|
function maybeCallbackWithError(callback, error, ...args) {
|
|
35
37
|
if (error !== void 0 && error !== null && !(error instanceof Error)) {
|
|
36
38
|
error = new Error(error);
|
|
@@ -44,12 +46,14 @@ function maybeCallbackWithError(callback, error, ...args) {
|
|
|
44
46
|
return Promise.resolve(args.length > 1 ? args : args[0]);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
49
|
+
__name(maybeCallbackWithError, "maybeCallbackWithError");
|
|
47
50
|
function maybeCallbackWithRedisError(callback, error, ...args) {
|
|
48
51
|
if (error instanceof Error && error.message.includes("Connection is closed")) {
|
|
49
52
|
error.message = import_tools.ERRORS.ERROR_DB_CLOSED;
|
|
50
53
|
}
|
|
51
54
|
return maybeCallbackWithError(callback, error, ...args);
|
|
52
55
|
}
|
|
56
|
+
__name(maybeCallbackWithRedisError, "maybeCallbackWithRedisError");
|
|
53
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
54
58
|
0 && (module.exports = {
|
|
55
59
|
maybeCallback,
|