@theotherwillembotha/node-red-plugincore 0.0.50
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/LICENSE +15 -0
- package/README.md +190 -0
- package/build/GenerateNodes.d.ts +2 -0
- package/build/GenerateNodes.d.ts.map +1 -0
- package/build/GenerateNodes.js +36 -0
- package/build/Nodes.html +1729 -0
- package/build/Nodes.js +32 -0
- package/build/Plugins.js +74 -0
- package/build/core/NodeConstructor.d.ts +188 -0
- package/build/core/NodeConstructor.d.ts.map +1 -0
- package/build/core/NodeConstructor.js +679 -0
- package/build/core/NodeGenerator.d.ts +37 -0
- package/build/core/NodeGenerator.d.ts.map +1 -0
- package/build/core/NodeGenerator.js +300 -0
- package/build/core/Utils.d.ts +7 -0
- package/build/core/Utils.d.ts.map +1 -0
- package/build/core/Utils.js +19 -0
- package/build/core/logger/LoggerDecorator.d.ts +2 -0
- package/build/core/logger/LoggerDecorator.d.ts.map +1 -0
- package/build/core/logger/LoggerDecorator.js +93 -0
- package/build/core/logger/node/ConsoleLoggerConfigNode.d.ts +16 -0
- package/build/core/logger/node/ConsoleLoggerConfigNode.d.ts.map +1 -0
- package/build/core/logger/node/ConsoleLoggerConfigNode.html +131 -0
- package/build/core/logger/node/ConsoleLoggerConfigNode.js +47 -0
- package/build/core/logger/node/LoggerConfigNode.d.ts +30 -0
- package/build/core/logger/node/LoggerConfigNode.d.ts.map +1 -0
- package/build/core/logger/node/LoggerConfigNode.html +307 -0
- package/build/core/logger/node/LoggerConfigNode.js +60 -0
- package/build/core/logger/node/LokiLoggerConfigNode.d.ts +20 -0
- package/build/core/logger/node/LokiLoggerConfigNode.d.ts.map +1 -0
- package/build/core/logger/node/LokiLoggerConfigNode.html +153 -0
- package/build/core/logger/node/LokiLoggerConfigNode.js +52 -0
- package/build/core/logger/node/RestLoggerConfigNode.d.ts +24 -0
- package/build/core/logger/node/RestLoggerConfigNode.d.ts.map +1 -0
- package/build/core/logger/node/RestLoggerConfigNode.html +209 -0
- package/build/core/logger/node/RestLoggerConfigNode.js +57 -0
- package/build/core/logger/service/LoggerService.d.ts +88 -0
- package/build/core/logger/service/LoggerService.d.ts.map +1 -0
- package/build/core/logger/service/LoggerService.js +204 -0
- package/build/core/logger/service/LoggerServiceTypes.d.ts +24 -0
- package/build/core/logger/service/LoggerServiceTypes.d.ts.map +1 -0
- package/build/core/logger/service/LoggerServiceTypes.js +30 -0
- package/build/core/logger/template/LoggerTemplate.d.ts +11 -0
- package/build/core/logger/template/LoggerTemplate.d.ts.map +1 -0
- package/build/core/logger/template/LoggerTemplate.html +328 -0
- package/build/core/logger/template/LoggerTemplate.js +12 -0
- package/build/core/metrics/MetricsDecorator.d.ts +40 -0
- package/build/core/metrics/MetricsDecorator.d.ts.map +1 -0
- package/build/core/metrics/MetricsDecorator.js +166 -0
- package/build/core/metrics/node/CounterMetricConfigNode.d.ts +16 -0
- package/build/core/metrics/node/CounterMetricConfigNode.d.ts.map +1 -0
- package/build/core/metrics/node/CounterMetricConfigNode.html +48 -0
- package/build/core/metrics/node/CounterMetricConfigNode.js +61 -0
- package/build/core/metrics/node/GaugeMetricConfigNode.d.ts +17 -0
- package/build/core/metrics/node/GaugeMetricConfigNode.d.ts.map +1 -0
- package/build/core/metrics/node/GaugeMetricConfigNode.html +48 -0
- package/build/core/metrics/node/GaugeMetricConfigNode.js +61 -0
- package/build/core/metrics/node/MetricsConfigNode.d.ts +14 -0
- package/build/core/metrics/node/MetricsConfigNode.d.ts.map +1 -0
- package/build/core/metrics/node/MetricsConfigNode.html +21 -0
- package/build/core/metrics/node/MetricsConfigNode.js +56 -0
- package/build/core/metrics/node/TimerMetricConfigNode.d.ts +28 -0
- package/build/core/metrics/node/TimerMetricConfigNode.d.ts.map +1 -0
- package/build/core/metrics/node/TimerMetricConfigNode.html +190 -0
- package/build/core/metrics/node/TimerMetricConfigNode.js +101 -0
- package/build/core/metrics/service/MetricsService.d.ts +187 -0
- package/build/core/metrics/service/MetricsService.d.ts.map +1 -0
- package/build/core/metrics/service/MetricsService.js +385 -0
- package/build/core/metrics/template/CounterMetricTemplate.d.ts +5 -0
- package/build/core/metrics/template/CounterMetricTemplate.d.ts.map +1 -0
- package/build/core/metrics/template/CounterMetricTemplate.html +40 -0
- package/build/core/metrics/template/CounterMetricTemplate.js +12 -0
- package/build/core/metrics/template/GaugeMetricTemplate.d.ts +5 -0
- package/build/core/metrics/template/GaugeMetricTemplate.d.ts.map +1 -0
- package/build/core/metrics/template/GaugeMetricTemplate.html +39 -0
- package/build/core/metrics/template/GaugeMetricTemplate.js +12 -0
- package/build/core/metrics/template/MetricsTemplate.d.ts +8 -0
- package/build/core/metrics/template/MetricsTemplate.d.ts.map +1 -0
- package/build/core/metrics/template/MetricsTemplate.html +54 -0
- package/build/core/metrics/template/MetricsTemplate.js +12 -0
- package/build/core/metrics/template/TimerMetricTemplate.d.ts +5 -0
- package/build/core/metrics/template/TimerMetricTemplate.d.ts.map +1 -0
- package/build/core/metrics/template/TimerMetricTemplate.html +39 -0
- package/build/core/metrics/template/TimerMetricTemplate.js +12 -0
- package/build/core/other/InputDecorator.d.ts +3 -0
- package/build/core/other/InputDecorator.d.ts.map +1 -0
- package/build/core/other/InputDecorator.js +43 -0
- package/build/core/other/service/InputService.d.ts +16 -0
- package/build/core/other/service/InputService.d.ts.map +1 -0
- package/build/core/other/service/InputService.js +31 -0
- package/build/core/other/service/SettingsService.d.ts +25 -0
- package/build/core/other/service/SettingsService.d.ts.map +1 -0
- package/build/core/other/service/SettingsService.js +74 -0
- package/build/core/other/template/BasicTemplate.d.ts +5 -0
- package/build/core/other/template/BasicTemplate.d.ts.map +1 -0
- package/build/core/other/template/BasicTemplate.html +76 -0
- package/build/core/other/template/BasicTemplate.js +11 -0
- package/build/core/other/template/SettingsTemplate.d.ts +5 -0
- package/build/core/other/template/SettingsTemplate.d.ts.map +1 -0
- package/build/core/other/template/SettingsTemplate.html +128 -0
- package/build/core/other/template/SettingsTemplate.js +11 -0
- package/build/core/tagging/NodeDescriptionDecorator.d.ts +17 -0
- package/build/core/tagging/NodeDescriptionDecorator.d.ts.map +1 -0
- package/build/core/tagging/NodeDescriptionDecorator.js +25 -0
- package/build/core/tagging/service/NodeTypeService.d.ts +15 -0
- package/build/core/tagging/service/NodeTypeService.d.ts.map +1 -0
- package/build/core/tagging/service/NodeTypeService.js +47 -0
- package/build/core/webhook/WebhookDecorator.d.ts +3 -0
- package/build/core/webhook/WebhookDecorator.d.ts.map +1 -0
- package/build/core/webhook/WebhookDecorator.js +45 -0
- package/build/core/webhook/node/WebhookServerConfigNode.d.ts +16 -0
- package/build/core/webhook/node/WebhookServerConfigNode.d.ts.map +1 -0
- package/build/core/webhook/node/WebhookServerConfigNode.html +61 -0
- package/build/core/webhook/node/WebhookServerConfigNode.js +40 -0
- package/build/core/webhook/service/ReverseProxyTypeService.d.ts +29 -0
- package/build/core/webhook/service/ReverseProxyTypeService.d.ts.map +1 -0
- package/build/core/webhook/service/ReverseProxyTypeService.js +24 -0
- package/build/core/webhook/service/WebhookServerService.d.ts +52 -0
- package/build/core/webhook/service/WebhookServerService.d.ts.map +1 -0
- package/build/core/webhook/service/WebhookServerService.js +146 -0
- package/build/core/webhook/template/WebhookTemplate.d.ts +22 -0
- package/build/core/webhook/template/WebhookTemplate.d.ts.map +1 -0
- package/build/core/webhook/template/WebhookTemplate.html +434 -0
- package/build/core/webhook/template/WebhookTemplate.js +12 -0
- package/build/index.d.ts +33 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +55 -0
- package/package.json +67 -0
- package/src/GenerateNodes.ts +42 -0
- package/src/core/NodeConstructor.ts +889 -0
- package/src/core/NodeGenerator.ts +331 -0
- package/src/core/Utils.ts +19 -0
- package/src/core/logger/LoggerDecorator.ts +105 -0
- package/src/core/logger/node/ConsoleLoggerConfigNode.html +131 -0
- package/src/core/logger/node/ConsoleLoggerConfigNode.ts +46 -0
- package/src/core/logger/node/LoggerConfigNode.html +307 -0
- package/src/core/logger/node/LoggerConfigNode.ts +95 -0
- package/src/core/logger/node/LokiLoggerConfigNode.html +153 -0
- package/src/core/logger/node/LokiLoggerConfigNode.ts +58 -0
- package/src/core/logger/node/RestLoggerConfigNode.html +209 -0
- package/src/core/logger/node/RestLoggerConfigNode.ts +67 -0
- package/src/core/logger/service/LoggerService.ts +317 -0
- package/src/core/logger/service/LoggerServiceTypes.ts +26 -0
- package/src/core/logger/template/LoggerTemplate.html +328 -0
- package/src/core/logger/template/LoggerTemplate.ts +23 -0
- package/src/core/metrics/MetricsDecorator.ts +227 -0
- package/src/core/metrics/node/CounterMetricConfigNode.html +48 -0
- package/src/core/metrics/node/CounterMetricConfigNode.ts +62 -0
- package/src/core/metrics/node/GaugeMetricConfigNode.html +48 -0
- package/src/core/metrics/node/GaugeMetricConfigNode.ts +62 -0
- package/src/core/metrics/node/MetricsConfigNode.html +21 -0
- package/src/core/metrics/node/MetricsConfigNode.ts +55 -0
- package/src/core/metrics/node/TimerMetricConfigNode.html +190 -0
- package/src/core/metrics/node/TimerMetricConfigNode.ts +118 -0
- package/src/core/metrics/service/MetricsService.ts +560 -0
- package/src/core/metrics/template/CounterMetricTemplate.html +40 -0
- package/src/core/metrics/template/CounterMetricTemplate.ts +15 -0
- package/src/core/metrics/template/GaugeMetricTemplate.html +39 -0
- package/src/core/metrics/template/GaugeMetricTemplate.ts +15 -0
- package/src/core/metrics/template/MetricsTemplate.html +54 -0
- package/src/core/metrics/template/MetricsTemplate.ts +18 -0
- package/src/core/metrics/template/TimerMetricTemplate.html +39 -0
- package/src/core/metrics/template/TimerMetricTemplate.ts +14 -0
- package/src/core/other/InputDecorator.ts +57 -0
- package/src/core/other/service/InputService.ts +36 -0
- package/src/core/other/service/SettingsService.ts +103 -0
- package/src/core/other/template/BasicTemplate.html +76 -0
- package/src/core/other/template/BasicTemplate.ts +15 -0
- package/src/core/other/template/SettingsTemplate.html +128 -0
- package/src/core/other/template/SettingsTemplate.ts +17 -0
- package/src/core/tagging/NodeDescriptionDecorator.ts +39 -0
- package/src/core/tagging/service/NodeTypeService.ts +67 -0
- package/src/core/webhook/WebhookDecorator.ts +70 -0
- package/src/core/webhook/node/WebhookServerConfigNode.html +61 -0
- package/src/core/webhook/node/WebhookServerConfigNode.ts +38 -0
- package/src/core/webhook/service/ReverseProxyTypeService.ts +46 -0
- package/src/core/webhook/service/WebhookServerService.ts +211 -0
- package/src/core/webhook/template/WebhookTemplate.html +434 -0
- package/src/core/webhook/template/WebhookTemplate.ts +36 -0
- package/src/index.ts +47 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Node } from "node-red";
|
|
2
|
+
import { ConfigNode, ConfigNodeConfig, NodeDescriptor } from "../../NodeConstructor";
|
|
3
|
+
import { Log, LoggerRegistration } from "../service/LoggerService";
|
|
4
|
+
import { ApiKeyMechanismType, Level, PlatformType, RestAuthType } from "../service/LoggerServiceTypes";
|
|
5
|
+
interface LoggerConfigNodeConfig extends ConfigNodeConfig {
|
|
6
|
+
id: string;
|
|
7
|
+
platform: PlatformType;
|
|
8
|
+
level: Level;
|
|
9
|
+
platfrom: PlatformType;
|
|
10
|
+
template: string;
|
|
11
|
+
platform_rest_url: string;
|
|
12
|
+
platform_rest_auth_type: RestAuthType;
|
|
13
|
+
platform_rest_auth_basic_username: string;
|
|
14
|
+
platform_rest_auth_basic_password: string;
|
|
15
|
+
platform_rest_auth_apikey_mechanism: ApiKeyMechanismType;
|
|
16
|
+
platform_rest_auth_apikey_name: string;
|
|
17
|
+
platform_rest_auth_apikey_value: string;
|
|
18
|
+
platform_loki_host: string;
|
|
19
|
+
platform_loki_userid?: string;
|
|
20
|
+
platform_loki_authtoken?: string;
|
|
21
|
+
platform_loki_tenantID?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class LoggerConfigNode extends ConfigNode<LoggerConfigNodeConfig> {
|
|
24
|
+
private _logger;
|
|
25
|
+
constructor(node: Node, config: LoggerConfigNodeConfig);
|
|
26
|
+
registerLogger(registration: LoggerRegistration): Log;
|
|
27
|
+
static getNodeDescriptor(): NodeDescriptor;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=LoggerConfigNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerConfigNode.d.ts","sourceRoot":"","sources":["../../../../src/core/logger/node/LoggerConfigNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAa,GAAG,EAAE,kBAAkB,EAAmC,MAAM,0BAA0B,CAAA;AAE9G,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEvG,UAAU,sBAAuB,SAAQ,gBAAgB;IAErD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAC,KAAK,CAAC;IACZ,QAAQ,EAAC,YAAY,CAAC;IACtB,QAAQ,EAAC,MAAM,CAAC;IAEhB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uBAAuB,EAAE,YAAY,CAAC;IACtC,iCAAiC,EAAC,MAAM,CAAC;IACzC,iCAAiC,EAAC,MAAM,CAAC;IACzC,mCAAmC,EAAC,mBAAmB,CAAC;IACxD,8BAA8B,EAAC,MAAM,CAAC;IACtC,+BAA+B,EAAC,MAAM,CAAC;IAEvC,kBAAkB,EAAC,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAC,MAAM,CAAC;IAC7B,uBAAuB,CAAC,EAAC,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAC,MAAM,CAAA;CACjC;AAED,qBAAa,gBAAiB,SAAQ,UAAU,CAAC,sBAAsB,CAAC;IAEpE,OAAO,CAAC,OAAO,CAAkB;gBAErB,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,sBAAsB;IAgD/C,cAAc,CAAC,YAAY,EAAC,kBAAkB,GAAE,GAAG;WAI1C,iBAAiB,IAAG,cAAc;CASrD"}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
|
|
2
|
+
<script type="text/javascript" template-section="onCompose">
|
|
3
|
+
node
|
|
4
|
+
.addDefault("name", {value:"Logger Example", required:true})
|
|
5
|
+
.addDefault("platform", {value:"rest", required:true})
|
|
6
|
+
.addDefault("template", {value:`message:{{msg}}`, required:true})
|
|
7
|
+
.addDefault("level", {value:"info", required:true})
|
|
8
|
+
|
|
9
|
+
// platform rest:
|
|
10
|
+
.addDefault("platform_rest_url", {})
|
|
11
|
+
.addDefault("platform_rest_ignoresslerror", {})
|
|
12
|
+
.addDefault("platform_rest_auth_type", {})
|
|
13
|
+
.addDefault("platform_rest_auth_basic_username", {})
|
|
14
|
+
.addDefault("platform_rest_auth_basic_password", {})
|
|
15
|
+
.addDefault("platform_rest_auth_apikey_mechanism", {})
|
|
16
|
+
.addDefault("platform_rest_auth_apikey_name", {})
|
|
17
|
+
.addDefault("platform_rest_auth_apikey_value", {})
|
|
18
|
+
|
|
19
|
+
// platform loki:
|
|
20
|
+
.addDefault("platform_loki_host", {})
|
|
21
|
+
.addDefault("platform_loki_tenantID", {})
|
|
22
|
+
.addDefault("platform_loki_userid", {})
|
|
23
|
+
.addDefault("platform_loki_authtoken", {})
|
|
24
|
+
|
|
25
|
+
.setPaletteLabel("Logger Config Node")
|
|
26
|
+
.setLabel(function() {return this.name })
|
|
27
|
+
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<script type="text/javascript" template-section="onIncludeEditPrepare">
|
|
31
|
+
{
|
|
32
|
+
let node = this;
|
|
33
|
+
|
|
34
|
+
let showSelectedPlatform = (value) => {
|
|
35
|
+
let loggerConfig = $("#LoggerConfig");
|
|
36
|
+
loggerConfig.find(".platform").each((i, t) => {
|
|
37
|
+
t = $(t);
|
|
38
|
+
if(t.hasClass(`platform-${value}`)){ t.show(); }
|
|
39
|
+
else { t.hide(); }
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
$("#LoggerConfig").find(`.platform-${value}`).find(`.platform-${value}-input.required`).each((i, entry) => {
|
|
43
|
+
let id = entry.id.replace("node-config-input-", "");
|
|
44
|
+
if(node._def.defaults[id]){
|
|
45
|
+
node._def.defaults[id].required = true;
|
|
46
|
+
}
|
|
47
|
+
else{
|
|
48
|
+
console.log(`you forgot to define ${id} in the defaults for LoggerConfigNode`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
Object.entries(node._def.defaults)
|
|
53
|
+
.filter(([k, v]) => k.startsWith(`platform_`))
|
|
54
|
+
.filter(([k, v]) => !k.startsWith(`platform_${value}_`))
|
|
55
|
+
.forEach(([k, v]) => v.required = false );
|
|
56
|
+
|
|
57
|
+
node.platform = value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let showSelectedRestAuthMethod = (value) => {
|
|
61
|
+
$("#LoggerConfig")
|
|
62
|
+
.find(".platform.platform-rest").first()
|
|
63
|
+
.find(".platform-rest-auth")
|
|
64
|
+
.each((i, t) => {
|
|
65
|
+
t = $(t);
|
|
66
|
+
if(t.hasClass(`auth-${value}`)){ t.show(); }
|
|
67
|
+
else { t.hide(); }
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let levelSelection = $("#node-config-input-level");
|
|
72
|
+
levelSelection.typedInput({type:"level", types:[{
|
|
73
|
+
value: "level",
|
|
74
|
+
options: [
|
|
75
|
+
{ value: "DEBUG", label: "debug"},
|
|
76
|
+
{ value: "INFO", label: "info"},
|
|
77
|
+
{ value: "WARNING", label: "warning"},
|
|
78
|
+
{ value: "ERROR", label: "error"},
|
|
79
|
+
]
|
|
80
|
+
}]});
|
|
81
|
+
|
|
82
|
+
let platformSelection = $("#node-config-input-platform");
|
|
83
|
+
platformSelection.typedInput({type:"platform", types:[{
|
|
84
|
+
value: "platform",
|
|
85
|
+
options: [
|
|
86
|
+
{ value: "console", label:"Console"},
|
|
87
|
+
{ value: "rest", label: "Http / Https"},
|
|
88
|
+
{ value: "loki", label: "Loki"},
|
|
89
|
+
// { value: "elasticsearch", label: "ElasticSearch"},
|
|
90
|
+
// { value: "datadog", label: "Datadog"},
|
|
91
|
+
// { value: "graylog", label: "Graylog"},
|
|
92
|
+
]
|
|
93
|
+
}]});
|
|
94
|
+
platformSelection.on("change", () => showSelectedPlatform(platformSelection.val()));
|
|
95
|
+
|
|
96
|
+
let platformRestAuthType = $("#node-config-input-platform_rest_auth_type");
|
|
97
|
+
platformRestAuthType.typedInput({type:"authtype", types:[{
|
|
98
|
+
value: "authtype",
|
|
99
|
+
options: [
|
|
100
|
+
{ value: "none", label: "None"},
|
|
101
|
+
{ value: "basic", label: "Basic"},
|
|
102
|
+
{ value: "apikey", label: "ApiKey"}
|
|
103
|
+
]
|
|
104
|
+
}]});
|
|
105
|
+
platformRestAuthType.on("change", () => showSelectedRestAuthMethod(platformRestAuthType.val()));
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
let apiKeyMechanism = $("#node-config-input-platform_rest_auth_apikey_mechanism");
|
|
109
|
+
apiKeyMechanism.typedInput({type:"apikeymechansim", types:[{
|
|
110
|
+
value: "apikeymechansim",
|
|
111
|
+
options: [
|
|
112
|
+
{ value: "header", label: "Header"},
|
|
113
|
+
{ value: "queryparam", label: "Query Param"},
|
|
114
|
+
{ value: "matrixparam", label: "Matrix Param"}
|
|
115
|
+
]
|
|
116
|
+
}]});
|
|
117
|
+
|
|
118
|
+
this.editor = RED.editor.createEditor({
|
|
119
|
+
id: 'node-config-input-templateEditor',
|
|
120
|
+
mode: 'ace/mode/handlebars',
|
|
121
|
+
value: this.template
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
// setup defaults //
|
|
126
|
+
if(node.platform){
|
|
127
|
+
platformSelection.typedInput('value',node.platform);
|
|
128
|
+
}
|
|
129
|
+
showSelectedPlatform(platformSelection.val());
|
|
130
|
+
}
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<script type="text/javascript" template-section="onIncludeEditSave">
|
|
134
|
+
{
|
|
135
|
+
let node = this;
|
|
136
|
+
|
|
137
|
+
this.template = this.editor.getValue();
|
|
138
|
+
this.editor.destroy();
|
|
139
|
+
delete this.editor;
|
|
140
|
+
|
|
141
|
+
// TODO: when saving the node, we need to remove all the platform_XXXX config values
|
|
142
|
+
// that are not supposed to be populated. For instance, when you switch from a loki to
|
|
143
|
+
// rest logger, the loki logger should be zeroed out.
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<script type="text/html" template-section="onIncludeEditForm">
|
|
149
|
+
<div id="LoggerConfig">
|
|
150
|
+
<div class="form-row">
|
|
151
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
152
|
+
<input type="text" id="node-config-input-name" />
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<div class="form-row">
|
|
156
|
+
<label for="node-config-input-level"><i class="fa fa-tag"></i> Level</label>
|
|
157
|
+
<input type="text" id="node-config-input-level" />
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<div class="form-row">
|
|
161
|
+
<label for="node-config-input-platform"><i class="fa fa-tag"></i> Platform</label>
|
|
162
|
+
<input type="text" id="node-config-input-platform" />
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<div class="platform platform-console">
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<div class="platform platform-rest">
|
|
169
|
+
<div class="form-row">
|
|
170
|
+
<label for="node-config-input-platform_rest_url"><i class="fa fa-tag"></i> URL</label>
|
|
171
|
+
<input class="platform-rest-input required" type="text" id="node-config-input-platform_rest_url" />
|
|
172
|
+
</div>
|
|
173
|
+
<div class="form-row">
|
|
174
|
+
<input type="checkbox" id="node-config-input-platform_rest_ignoresslerror" style="margin:8px 0 10px 102px; width:20px;" />
|
|
175
|
+
<label style="width:auto" for="node-config-input-platform_rest_ignoresslerror"><span>Ignore Invalid SSL certificates</span></label>
|
|
176
|
+
</div>
|
|
177
|
+
<div class="form-row">
|
|
178
|
+
<label for="node-config-input-platform_rest_auth_type"><i class="fa fa-tag"></i> Authentication</label>
|
|
179
|
+
<input class="platform-rest-input required" type="text" id="node-config-input-platform_rest_auth_type" />
|
|
180
|
+
</div>
|
|
181
|
+
<div class="form-row platform-rest-auth auth-basic">
|
|
182
|
+
<label for="node-config-input-platform_rest_auth_basic_username"><i class="fa fa-tag"></i> Username</label>
|
|
183
|
+
<input class="platform-rest-input" type="text" id="node-config-input-platform_rest_auth_basic_username" />
|
|
184
|
+
</div>
|
|
185
|
+
<div class="form-row platform-rest-auth auth-basic">
|
|
186
|
+
<label for="node-config-input-platform_rest_auth_basic_password"><i class="fa fa-tag"></i> Password</label>
|
|
187
|
+
<input class="platform-rest-input" type="password" id="node-config-input-platform_rest_auth_basic_password" />
|
|
188
|
+
</div>
|
|
189
|
+
<div class="form-row platform-rest-auth auth-apikey">
|
|
190
|
+
<label for="node-config-input-platform_rest_auth_apikey_mechanism"><i class="fa fa-tag"></i> Mechanism</label>
|
|
191
|
+
<input class="platform-rest-input" type="text" id="node-config-input-platform_rest_auth_apikey_mechanism" />
|
|
192
|
+
</div>
|
|
193
|
+
<div class="form-row platform-rest-auth auth-apikey">
|
|
194
|
+
<label for="node-config-input-platform_rest_auth_apikey_name"><i class="fa fa-tag"></i> APIKey name</label>
|
|
195
|
+
<input class="platform-rest-input" type="text" id="node-config-input-platform_rest_auth_apikey_name" />
|
|
196
|
+
</div>
|
|
197
|
+
<div class="form-row platform-rest-auth auth-apikey">
|
|
198
|
+
<label for="node-config-input-platform_rest_auth_apikey_value"><i class="fa fa-tag"></i> APIKey value</label>
|
|
199
|
+
<input class="platform-rest-input" type="text" id="node-config-input-platform_rest_auth_apikey_value" />
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<div class="platform platform-loki">
|
|
204
|
+
<div class="form-row">
|
|
205
|
+
<label for="node-config-input-platform_loki_host"><i class="fa fa-tag"></i> Host</label>
|
|
206
|
+
<input class="platform-loki-input required" type="text" id="node-config-input-platform_loki_host" />
|
|
207
|
+
</div>
|
|
208
|
+
<div class="form-row">
|
|
209
|
+
<label for="node-config-input-platform_loki_tenantID"><i class="fa fa-tag"></i> TenantID</label>
|
|
210
|
+
<input class="platform-loki-input" type="text" id="node-config-input-platform_loki_tenantID" />
|
|
211
|
+
</div>
|
|
212
|
+
<div class="form-row">
|
|
213
|
+
<label for="node-config-input-platform_loki_userid"><i class="fa fa-tag"></i> Username</label>
|
|
214
|
+
<input class="platform-loki-input" type="text" id="node-config-input-platform_loki_userid" />
|
|
215
|
+
</div>
|
|
216
|
+
<div class="form-row">
|
|
217
|
+
<label for="node-config-input-platform_loki_authtoken"><i class="fa fa-tag"></i> AuthToken</label>
|
|
218
|
+
<input class="platform-loki-input" type="password" id="node-config-input-platform_loki_authtoken" />
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
<div class="platform platform-elasticsearch">
|
|
223
|
+
ELASTIC SEARCH
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<div class="platform platform-datadog">
|
|
227
|
+
DATADOG
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<div class="platform platform-graylog">
|
|
231
|
+
GRAYLOG
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
<div class="form-row">
|
|
235
|
+
<label for="node-config-input-templateEditor"><i class="fa fa-tag"></i> Template</label>
|
|
236
|
+
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-config-input-templateEditor"></div>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</script>
|
|
240
|
+
|
|
241
|
+
<script type="text/markdown" template-section="onIncludeDocumentation">
|
|
242
|
+
Configuration node for the Logger Integration
|
|
243
|
+
|
|
244
|
+
## Inputs
|
|
245
|
+
: *name* (string) : The common name for the logger Configuration
|
|
246
|
+
: *level* (level) : The logging level - debug, info, warning, error
|
|
247
|
+
: *platform*(string) : The common name for the logger Configuration
|
|
248
|
+
: *template*(mustache) : A template for the log messages.
|
|
249
|
+
|
|
250
|
+
## Logger platform
|
|
251
|
+
Currently supported logging platforms
|
|
252
|
+
|
|
253
|
+
### Console
|
|
254
|
+
The log message will be printed out to stdio
|
|
255
|
+
|
|
256
|
+
### Http / Https
|
|
257
|
+
Publish the message to an http endpoint using a http / https POST command.
|
|
258
|
+
|
|
259
|
+
: *url* (url) : The endpoint for the url where requests are to be posted to.
|
|
260
|
+
: *ignore ssl errors* (boolean) : If enabled, the invalid ssl certificates will be ignored.
|
|
261
|
+
: *authentication* (auth method) : what auth method should be used for the http request. (none, basic, api key)
|
|
262
|
+
|
|
263
|
+
#### Authentication
|
|
264
|
+
##### Basic
|
|
265
|
+
Provides basic authentication using the Authorization header
|
|
266
|
+
|
|
267
|
+
: *username* (string) : the username used for basic authentication
|
|
268
|
+
: *password* (string) : the password used for basic authentication
|
|
269
|
+
|
|
270
|
+
##### APIKey
|
|
271
|
+
Provides authentication using a matrix parameter, header or query parameter and an apikey
|
|
272
|
+
|
|
273
|
+
: *mechanism* (mechanism) : the mechanism that will be used for transmitting the key (header, queryparam, matrixparam)
|
|
274
|
+
: *apikey name* (string) : the name of the key used for api authentication. (path variable or query param name)
|
|
275
|
+
: *apikey value*(string) : the value of the api key that will be transmitted. (beware of special characters)
|
|
276
|
+
|
|
277
|
+
### Loki
|
|
278
|
+
Publish the message to a loki endpoint.
|
|
279
|
+
|
|
280
|
+
: *host* (string) : the host and port\ of the loki instance that it being logged to
|
|
281
|
+
: *tenant* (string) : the tenant id that will be used to log to
|
|
282
|
+
: *username* (string) : the username for the loki instance.
|
|
283
|
+
: *authtoken* (string) : the authtoken for the loki instance.
|
|
284
|
+
|
|
285
|
+
# Mustache Templating
|
|
286
|
+
Mustache / Handlebars are used for building up the logged message payloads that are sent to the logging backend.
|
|
287
|
+
The resultant message will be interpreted as a string, meaning care should be taken in the event that a string representation of a json object is built.
|
|
288
|
+
|
|
289
|
+
### Provided Properties
|
|
290
|
+
A couple of values are provided to the logging context by default.
|
|
291
|
+
|
|
292
|
+
: *msg* (object) : an object containing the payload or message that should be parsed through the template.
|
|
293
|
+
: *currentTime* (object) : a string containing the current time in ISO8601 format
|
|
294
|
+
|
|
295
|
+
### Mustache Helpers
|
|
296
|
+
In addition to the provided properties, some "helpers" have also been provided to assist in serialization.
|
|
297
|
+
|
|
298
|
+
: *json* (helper) : converts a json object to a string using the JSON.stringify method.
|
|
299
|
+
|
|
300
|
+
## Examples
|
|
301
|
+
- {{{json msg}}} - serializes the the msg object to json format.
|
|
302
|
+
|
|
303
|
+
# References
|
|
304
|
+
- [Mustache - Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
|
|
305
|
+
- [Mustache - Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
|
|
306
|
+
</script>
|
|
307
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggerConfigNode = void 0;
|
|
4
|
+
const NodeConstructor_1 = require("../../NodeConstructor");
|
|
5
|
+
const LoggerService_1 = require("../service/LoggerService");
|
|
6
|
+
const NodeGenerator_1 = require("../../NodeGenerator");
|
|
7
|
+
const LoggerServiceTypes_1 = require("../service/LoggerServiceTypes");
|
|
8
|
+
class LoggerConfigNode extends NodeConstructor_1.ConfigNode {
|
|
9
|
+
constructor(node, config) {
|
|
10
|
+
super(node, config);
|
|
11
|
+
let _this = this;
|
|
12
|
+
// instantiate the logger.
|
|
13
|
+
let loggerConfig;
|
|
14
|
+
if (config.platform === LoggerServiceTypes_1.PlatformType.console) {
|
|
15
|
+
loggerConfig = {
|
|
16
|
+
id: this.id(),
|
|
17
|
+
type: LoggerServiceTypes_1.PlatformType.console,
|
|
18
|
+
template: config.template,
|
|
19
|
+
level: config.level,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
if (config.platform === LoggerServiceTypes_1.PlatformType.rest) {
|
|
23
|
+
loggerConfig = {
|
|
24
|
+
id: this.id(),
|
|
25
|
+
type: LoggerServiceTypes_1.PlatformType.rest,
|
|
26
|
+
template: config.template,
|
|
27
|
+
level: config.level,
|
|
28
|
+
url: config.platform_rest_url,
|
|
29
|
+
auth_type: config.platform_rest_auth_type,
|
|
30
|
+
auth_basic_username: config.platform_rest_auth_basic_username,
|
|
31
|
+
auth_basic_password: config.platform_rest_auth_basic_password,
|
|
32
|
+
auth_apikey_mechanism: config.platform_rest_auth_apikey_mechanism,
|
|
33
|
+
auth_apikey_name: config.platform_rest_auth_apikey_name,
|
|
34
|
+
auth_apikey_value: config.platform_rest_auth_apikey_value,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (config.platform === LoggerServiceTypes_1.PlatformType.loki) {
|
|
38
|
+
loggerConfig = {
|
|
39
|
+
id: this.id(),
|
|
40
|
+
type: LoggerServiceTypes_1.PlatformType.loki,
|
|
41
|
+
template: config.template,
|
|
42
|
+
level: config.level,
|
|
43
|
+
host: config.platform_loki_host,
|
|
44
|
+
userid: config.platform_loki_userid,
|
|
45
|
+
authtoken: config.platform_loki_authtoken,
|
|
46
|
+
tenantID: config.platform_loki_tenantID,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
this._logger = LoggerService_1.LoggerService.get(loggerConfig);
|
|
50
|
+
}
|
|
51
|
+
registerLogger(registration) {
|
|
52
|
+
return this._logger.register(registration);
|
|
53
|
+
}
|
|
54
|
+
static getNodeDescriptor() {
|
|
55
|
+
return new NodeConstructor_1.NodeDescriptor("config", "LoggerConfigNode", NodeGenerator_1.SourceUtility.getSourcePath("/build/", "/src/") + "LoggerConfigNode.html", "@theotherwillembotha/node-red-plugincore")
|
|
56
|
+
.addDependency(LoggerService_1.LoggerService)
|
|
57
|
+
.addTag("Core");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.LoggerConfigNode = LoggerConfigNode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Node } from "node-red";
|
|
2
|
+
import { ConfigNode, ConfigNodeConfig } from "../../NodeConstructor";
|
|
3
|
+
import { Log, LoggerRegistration } from "../service/LoggerService";
|
|
4
|
+
import { Level } from "../service/LoggerServiceTypes";
|
|
5
|
+
interface LokiLoggerConfigNodeConfig extends ConfigNodeConfig {
|
|
6
|
+
id: string;
|
|
7
|
+
level: Level;
|
|
8
|
+
template: string;
|
|
9
|
+
loki_host: string;
|
|
10
|
+
loki_userid?: string;
|
|
11
|
+
loki_authtoken?: string;
|
|
12
|
+
loki_tenantID?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class LokiLoggerConfigNode extends ConfigNode<LokiLoggerConfigNodeConfig> {
|
|
15
|
+
private _logger;
|
|
16
|
+
constructor(node: Node, config: LokiLoggerConfigNodeConfig);
|
|
17
|
+
registerLogger(registration: LoggerRegistration): Log;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=LokiLoggerConfigNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LokiLoggerConfigNode.d.ts","sourceRoot":"","sources":["../../../../src/core/logger/node/LokiLoggerConfigNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAa,GAAG,EAAE,kBAAkB,EAAiB,MAAM,0BAA0B,CAAA;AAE5F,OAAO,EAAE,KAAK,EAAgB,MAAM,+BAA+B,CAAC;AAGpE,UAAU,0BAA2B,SAAQ,gBAAgB;IAEzD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAC,KAAK,CAAC;IACZ,QAAQ,EAAC,MAAM,CAAC;IAEhB,SAAS,EAAC,MAAM,CAAC;IACjB,WAAW,CAAC,EAAC,MAAM,CAAC;IACpB,cAAc,CAAC,EAAC,MAAM,CAAC;IACvB,aAAa,CAAC,EAAC,MAAM,CAAA;CACxB;AAED,qBASa,oBAAqB,SAAQ,UAAU,CAAC,0BAA0B,CAAC;IAE5E,OAAO,CAAC,OAAO,CAAkB;gBAErB,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,0BAA0B;IAqBnD,cAAc,CAAC,YAAY,EAAC,kBAAkB,GAAE,GAAG;CAG7D"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
|
|
2
|
+
<script type="text/javascript" template-section="onCompose">
|
|
3
|
+
node
|
|
4
|
+
.addDefault("name", {value:"Logger Example", required:true})
|
|
5
|
+
.addDefault("template", {value:`message:{{msg}}`, required:true})
|
|
6
|
+
.addDefault("level", {value:"info", required:true})
|
|
7
|
+
|
|
8
|
+
.addDefault("loki_host", {})
|
|
9
|
+
.addDefault("loki_tenantID", {})
|
|
10
|
+
.addDefault("loki_userid", {})
|
|
11
|
+
.addDefault("loki_authtoken", {})
|
|
12
|
+
|
|
13
|
+
.setPaletteLabel("Loki Logger Config Node")
|
|
14
|
+
.setLabel(function() {return this.name })
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/javascript" template-section="onIncludeEditPrepare">
|
|
18
|
+
{
|
|
19
|
+
let node = this;
|
|
20
|
+
|
|
21
|
+
let levelSelection = $("#node-config-input-level");
|
|
22
|
+
levelSelection.typedInput({type:"level", types:[{
|
|
23
|
+
value: "level",
|
|
24
|
+
options: [
|
|
25
|
+
{ value: "DEBUG", label: "debug"},
|
|
26
|
+
{ value: "INFO", label: "info"},
|
|
27
|
+
{ value: "WARNING", label: "warning"},
|
|
28
|
+
{ value: "ERROR", label: "error"},
|
|
29
|
+
]
|
|
30
|
+
}]});
|
|
31
|
+
|
|
32
|
+
this.editor = RED.editor.createEditor({
|
|
33
|
+
id: 'node-config-input-templateEditor',
|
|
34
|
+
mode: 'ace/mode/handlebars',
|
|
35
|
+
value: this.template
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<script type="text/javascript" template-section="onIncludeEditSave">
|
|
41
|
+
{
|
|
42
|
+
let node = this;
|
|
43
|
+
|
|
44
|
+
this.template = this.editor.getValue();
|
|
45
|
+
this.editor.destroy();
|
|
46
|
+
delete this.editor;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<script type="text/html" template-section="onIncludeEditForm">
|
|
52
|
+
<div id="LoggerConfig">
|
|
53
|
+
<div class="form-row">
|
|
54
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
55
|
+
<input type="text" id="node-config-input-name" />
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div class="form-row">
|
|
59
|
+
<label for="node-config-input-level"><i class="fa fa-tag"></i> Level</label>
|
|
60
|
+
<input type="text" id="node-config-input-level" />
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<div class="form-row">
|
|
64
|
+
<label for="node-config-input-loki_host"><i class="fa fa-tag"></i> Host</label>
|
|
65
|
+
<input class="required" type="text" id="node-config-input-loki_host" />
|
|
66
|
+
</div>
|
|
67
|
+
<div class="form-row">
|
|
68
|
+
<label for="node-config-input-loki_tenantID"><i class="fa fa-tag"></i> TenantID</label>
|
|
69
|
+
<input class="" type="text" id="node-config-input-loki_tenantID" />
|
|
70
|
+
</div>
|
|
71
|
+
<div class="form-row">
|
|
72
|
+
<label for="node-config-input-loki_userid"><i class="fa fa-tag"></i> Username</label>
|
|
73
|
+
<input class="" type="text" id="node-config-input-loki_userid" />
|
|
74
|
+
</div>
|
|
75
|
+
<div class="form-row">
|
|
76
|
+
<label for="node-config-input-loki_authtoken"><i class="fa fa-tag"></i> AuthToken</label>
|
|
77
|
+
<input class="" type="password" id="node-config-input-loki_authtoken" />
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div class="form-row">
|
|
81
|
+
<label for="node-config-input-templateEditor"><i class="fa fa-tag"></i> Template</label>
|
|
82
|
+
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-config-input-templateEditor"></div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<script type="text/markdown" template-section="onIncludeDocumentation">
|
|
88
|
+
Configuration node for the Logger Integration
|
|
89
|
+
|
|
90
|
+
## Inputs
|
|
91
|
+
: *name* (string) : The common name for the logger Configuration
|
|
92
|
+
: *level* (level) : The logging level - debug, info, warning, error
|
|
93
|
+
: *platform*(string) : The common name for the logger Configuration
|
|
94
|
+
: *template*(mustache) : A template for the log messages.
|
|
95
|
+
|
|
96
|
+
## Logger platform
|
|
97
|
+
Currently supported logging platforms
|
|
98
|
+
|
|
99
|
+
### Console
|
|
100
|
+
The log message will be printed out to stdio
|
|
101
|
+
|
|
102
|
+
### Http / Https
|
|
103
|
+
Publish the message to an http endpoint using a http / https POST command.
|
|
104
|
+
|
|
105
|
+
: *url* (url) : The endpoint for the url where requests are to be posted to.
|
|
106
|
+
: *ignore ssl errors* (boolean) : If enabled, the invalid ssl certificates will be ignored.
|
|
107
|
+
: *authentication* (auth method) : what auth method should be used for the http request. (none, basic, api key)
|
|
108
|
+
|
|
109
|
+
#### Authentication
|
|
110
|
+
##### Basic
|
|
111
|
+
Provides basic authentication using the Authorization header
|
|
112
|
+
|
|
113
|
+
: *username* (string) : the username used for basic authentication
|
|
114
|
+
: *password* (string) : the password used for basic authentication
|
|
115
|
+
|
|
116
|
+
##### APIKey
|
|
117
|
+
Provides authentication using a matrix parameter, header or query parameter and an apikey
|
|
118
|
+
|
|
119
|
+
: *mechanism* (mechanism) : the mechanism that will be used for transmitting the key (header, queryparam, matrixparam)
|
|
120
|
+
: *apikey name* (string) : the name of the key used for api authentication. (path variable or query param name)
|
|
121
|
+
: *apikey value*(string) : the value of the api key that will be transmitted. (beware of special characters)
|
|
122
|
+
|
|
123
|
+
### Loki
|
|
124
|
+
Publish the message to a loki endpoint.
|
|
125
|
+
|
|
126
|
+
: *host* (string) : the host and port\ of the loki instance that it being logged to
|
|
127
|
+
: *tenant* (string) : the tenant id that will be used to log to
|
|
128
|
+
: *username* (string) : the username for the loki instance.
|
|
129
|
+
: *authtoken* (string) : the authtoken for the loki instance.
|
|
130
|
+
|
|
131
|
+
# Mustache Templating
|
|
132
|
+
Mustache / Handlebars are used for building up the logged message payloads that are sent to the logging backend.
|
|
133
|
+
The resultant message will be interpreted as a string, meaning care should be taken in the event that a string representation of a json object is built.
|
|
134
|
+
|
|
135
|
+
### Provided Properties
|
|
136
|
+
A couple of values are provided to the logging context by default.
|
|
137
|
+
|
|
138
|
+
: *msg* (object) : an object containing the payload or message that should be parsed through the template.
|
|
139
|
+
: *currentTime* (object) : a string containing the current time in ISO8601 format
|
|
140
|
+
|
|
141
|
+
### Mustache Helpers
|
|
142
|
+
In addition to the provided properties, some "helpers" have also been provided to assist in serialization.
|
|
143
|
+
|
|
144
|
+
: *json* (helper) : converts a json object to a string using the JSON.stringify method.
|
|
145
|
+
|
|
146
|
+
## Examples
|
|
147
|
+
- {{{json msg}}} - serializes the the msg object to json format.
|
|
148
|
+
|
|
149
|
+
# References
|
|
150
|
+
- [Mustache - Wikipedia](https://en.wikipedia.org/wiki/Mustache_(template_system))
|
|
151
|
+
- [Mustache - Playground](https://jgonggrijp.gitlab.io/wontache/playground.html)
|
|
152
|
+
</script>
|
|
153
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LokiLoggerConfigNode = void 0;
|
|
13
|
+
const NodeConstructor_1 = require("../../NodeConstructor");
|
|
14
|
+
const LoggerService_1 = require("../service/LoggerService");
|
|
15
|
+
const NodeGenerator_1 = require("../../NodeGenerator");
|
|
16
|
+
const LoggerServiceTypes_1 = require("../service/LoggerServiceTypes");
|
|
17
|
+
const NodeDescriptionDecorator_1 = require("../../tagging/NodeDescriptionDecorator");
|
|
18
|
+
let LokiLoggerConfigNode = class LokiLoggerConfigNode extends NodeConstructor_1.ConfigNode {
|
|
19
|
+
constructor(node, config) {
|
|
20
|
+
super(node, config);
|
|
21
|
+
let _this = this;
|
|
22
|
+
// instantiate the logger.
|
|
23
|
+
let loggerConfig;
|
|
24
|
+
loggerConfig = {
|
|
25
|
+
id: this.id(),
|
|
26
|
+
type: LoggerServiceTypes_1.PlatformType.loki,
|
|
27
|
+
template: config.template,
|
|
28
|
+
level: config.level,
|
|
29
|
+
host: config.loki_host,
|
|
30
|
+
userid: config.loki_userid,
|
|
31
|
+
authtoken: config.loki_authtoken,
|
|
32
|
+
tenantID: config.loki_tenantID,
|
|
33
|
+
};
|
|
34
|
+
this._logger = LoggerService_1.LoggerService.get(loggerConfig);
|
|
35
|
+
}
|
|
36
|
+
registerLogger(registration) {
|
|
37
|
+
return this._logger.register(registration);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.LokiLoggerConfigNode = LokiLoggerConfigNode;
|
|
41
|
+
exports.LokiLoggerConfigNode = LokiLoggerConfigNode = __decorate([
|
|
42
|
+
(0, NodeDescriptionDecorator_1.NodeDescription)({
|
|
43
|
+
id: "LokiLoggerConfigNode",
|
|
44
|
+
name: "Loki Logger",
|
|
45
|
+
group: "config",
|
|
46
|
+
sourceFile: NodeGenerator_1.SourceUtility.getSourcePath("/build/", "/src/") + "LokiLoggerConfigNode.html",
|
|
47
|
+
package: "@theotherwillembotha/node-red-plugincore",
|
|
48
|
+
dependencies: [LoggerService_1.LoggerService],
|
|
49
|
+
tags: ["LoggerType"]
|
|
50
|
+
}),
|
|
51
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
52
|
+
], LokiLoggerConfigNode);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Node } from "node-red";
|
|
2
|
+
import { ConfigNode, ConfigNodeConfig } from "../../NodeConstructor";
|
|
3
|
+
import { Log, LoggerRegistration } from "../service/LoggerService";
|
|
4
|
+
import { ApiKeyMechanismType, Level, PlatformType, RestAuthType } from "../service/LoggerServiceTypes";
|
|
5
|
+
interface RestLoggerConfigNodeConfig extends ConfigNodeConfig {
|
|
6
|
+
id: string;
|
|
7
|
+
platform: PlatformType;
|
|
8
|
+
level: Level;
|
|
9
|
+
template: string;
|
|
10
|
+
rest_url: string;
|
|
11
|
+
rest_auth_type: RestAuthType;
|
|
12
|
+
rest_auth_basic_username: string;
|
|
13
|
+
rest_auth_basic_password: string;
|
|
14
|
+
rest_auth_apikey_mechanism: ApiKeyMechanismType;
|
|
15
|
+
rest_auth_apikey_name: string;
|
|
16
|
+
rest_auth_apikey_value: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class RestLoggerConfigNode extends ConfigNode<RestLoggerConfigNodeConfig> {
|
|
19
|
+
private _logger;
|
|
20
|
+
constructor(node: Node, config: RestLoggerConfigNodeConfig);
|
|
21
|
+
registerLogger(registration: LoggerRegistration): Log;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=RestLoggerConfigNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RestLoggerConfigNode.d.ts","sourceRoot":"","sources":["../../../../src/core/logger/node/RestLoggerConfigNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAkB,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAa,GAAG,EAAE,kBAAkB,EAAmC,MAAM,0BAA0B,CAAA;AAE9G,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGvG,UAAU,0BAA2B,SAAQ,gBAAgB;IAEzD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAC,KAAK,CAAC;IACZ,QAAQ,EAAC,MAAM,CAAC;IAEhB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,YAAY,CAAC;IAC7B,wBAAwB,EAAC,MAAM,CAAC;IAChC,wBAAwB,EAAC,MAAM,CAAC;IAChC,0BAA0B,EAAC,mBAAmB,CAAC;IAC/C,qBAAqB,EAAC,MAAM,CAAC;IAC7B,sBAAsB,EAAC,MAAM,CAAC;CACjC;AAED,qBASa,oBAAqB,SAAQ,UAAU,CAAC,0BAA0B,CAAC;IAE5E,OAAO,CAAC,OAAO,CAAkB;gBAErB,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,0BAA0B;IA0BnD,cAAc,CAAC,YAAY,EAAC,kBAAkB,GAAE,GAAG;CAG7D"}
|