@spinajs/log-source-graphana-loki 2.0.45 → 2.0.48
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/README.md +11 -11
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +25 -23
- package/lib/index.js.map +1 -1
- package/package.json +53 -51
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# `@spinajs/log-common`
|
|
2
|
-
|
|
3
|
-
> TODO: description
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
const logCommon = require('@spinajs/log-common');
|
|
9
|
-
|
|
10
|
-
// TODO: DEMONSTRATE API
|
|
11
|
-
```
|
|
1
|
+
# `@spinajs/log-common`
|
|
2
|
+
|
|
3
|
+
> TODO: description
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
const logCommon = require('@spinajs/log-common');
|
|
9
|
+
|
|
10
|
+
// TODO: DEMONSTRATE API
|
|
11
|
+
```
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { IInstanceCheck } from "@spinajs/di";
|
|
3
|
-
import { ILog, ILogEntry, LogTarget, ICommonTargetOptions } from "@spinajs/log
|
|
3
|
+
import { ILog, ILogEntry, LogTarget, ICommonTargetOptions } from "@spinajs/log";
|
|
4
4
|
export interface IGraphanaOptions extends ICommonTargetOptions {
|
|
5
5
|
options: {
|
|
6
6
|
interval: number;
|
|
@@ -30,3 +30,4 @@ export declare class GraphanaLokiLogTarget extends LogTarget<IGraphanaOptions> i
|
|
|
30
30
|
protected flush(): void;
|
|
31
31
|
}
|
|
32
32
|
export {};
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAgC,MAAM,aAAa,CAAC;AAC3E,OAAO,EACL,IAAI,EACJ,SAAS,EACT,SAAS,EACT,oBAAoB,EAErB,MAAM,cAAc,CAAC;AAKtB,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC5D,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE;YACN,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;KACH,CAAC;CACH;AAYD,aAAK,YAAY;IACf,QAAQ,IAAA;IACR,OAAO,IAAA;IACP,IAAI,IAAA;CACL;AAID,qBAEa,qBACX,SAAQ,SAAS,CAAC,gBAAgB,CAClC,YAAW,cAAc;IAGzB,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC;IAEpB,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,CAAM;IAEpC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAqB;IAEnD,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC;gBAEvB,OAAO,EAAE,gBAAgB;IAarC,iBAAiB,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO;IAItD,OAAO,IAAI,IAAI;IAaf,KAAK,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAwBtB,OAAO;IAQpB,SAAS,CAAC,KAAK;CA6DhB"}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,19 +7,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.GraphanaLokiLogTarget = void 0;
|
|
16
10
|
/* eslint-disable promise/always-return */
|
|
17
11
|
/* eslint-disable security/detect-object-injection */
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
12
|
+
import { format } from "@spinajs/configuration-common";
|
|
13
|
+
import { Injectable, PerInstanceCheck } from "@spinajs/di";
|
|
14
|
+
import { LogTarget, Logger, } from "@spinajs/log";
|
|
15
|
+
import axios from "axios";
|
|
16
|
+
import _ from "lodash";
|
|
24
17
|
var TargetStatus;
|
|
25
18
|
(function (TargetStatus) {
|
|
26
19
|
TargetStatus[TargetStatus["WRITTING"] = 0] = "WRITTING";
|
|
@@ -29,7 +22,7 @@ var TargetStatus;
|
|
|
29
22
|
})(TargetStatus || (TargetStatus = {}));
|
|
30
23
|
// we mark per instance check becouse we can have multiple file targes
|
|
31
24
|
// for different files/paths/logs but we dont want to create every time writer for same.
|
|
32
|
-
let GraphanaLokiLogTarget = class GraphanaLokiLogTarget extends
|
|
25
|
+
let GraphanaLokiLogTarget = class GraphanaLokiLogTarget extends LogTarget {
|
|
33
26
|
constructor(options) {
|
|
34
27
|
super(options);
|
|
35
28
|
this.Entries = [];
|
|
@@ -44,7 +37,6 @@ let GraphanaLokiLogTarget = class GraphanaLokiLogTarget extends log_common_1.Log
|
|
|
44
37
|
return this.Options.name === creationOptions.name;
|
|
45
38
|
}
|
|
46
39
|
resolve() {
|
|
47
|
-
var _a;
|
|
48
40
|
this.FlushTimer = setInterval(() => {
|
|
49
41
|
// do not flush, if we already writting to file
|
|
50
42
|
if (this.Status !== TargetStatus.IDLE) {
|
|
@@ -53,7 +45,7 @@ let GraphanaLokiLogTarget = class GraphanaLokiLogTarget extends log_common_1.Log
|
|
|
53
45
|
setImmediate(() => {
|
|
54
46
|
this.flush();
|
|
55
47
|
});
|
|
56
|
-
},
|
|
48
|
+
}, this.Options.options.interval ?? 3000);
|
|
57
49
|
}
|
|
58
50
|
write(data) {
|
|
59
51
|
if (!this.Options.enabled) {
|
|
@@ -88,20 +80,30 @@ let GraphanaLokiLogTarget = class GraphanaLokiLogTarget extends log_common_1.Log
|
|
|
88
80
|
}
|
|
89
81
|
this.Status = TargetStatus.WRITTING;
|
|
90
82
|
this.Entries.forEach((entry) => {
|
|
91
|
-
let stream = batch.find((b) =>
|
|
83
|
+
let stream = batch.find((b) => _.isEqual(b.labels, {
|
|
84
|
+
app: this.Options.options.labels.app,
|
|
85
|
+
logger: entry.Variables.logger,
|
|
86
|
+
level: entry.Variables.level,
|
|
87
|
+
...this.Options.options.labels,
|
|
88
|
+
}));
|
|
92
89
|
if (!stream) {
|
|
93
90
|
stream = {
|
|
94
|
-
labels:
|
|
91
|
+
labels: {
|
|
92
|
+
app: this.Options.options.labels.app,
|
|
93
|
+
logger: entry.Variables.logger,
|
|
94
|
+
level: entry.Variables.level,
|
|
95
|
+
...this.Options.options.labels,
|
|
96
|
+
},
|
|
95
97
|
values: [],
|
|
96
98
|
};
|
|
97
99
|
batch.push(stream);
|
|
98
100
|
}
|
|
99
101
|
stream.values.push([
|
|
100
102
|
entry.Variables["n_timestamp"],
|
|
101
|
-
JSON.stringify(
|
|
103
|
+
JSON.stringify(format(entry.Variables, this.Options.layout)),
|
|
102
104
|
]);
|
|
103
105
|
});
|
|
104
|
-
|
|
106
|
+
axios
|
|
105
107
|
.post(this.Options.options.host + "/loki/api/v1/push", {
|
|
106
108
|
headers: {
|
|
107
109
|
"Content-Type": "application/json",
|
|
@@ -122,13 +124,13 @@ let GraphanaLokiLogTarget = class GraphanaLokiLogTarget extends log_common_1.Log
|
|
|
122
124
|
}
|
|
123
125
|
};
|
|
124
126
|
__decorate([
|
|
125
|
-
|
|
127
|
+
Logger("LogLokiTarget"),
|
|
126
128
|
__metadata("design:type", Object)
|
|
127
129
|
], GraphanaLokiLogTarget.prototype, "Log", void 0);
|
|
128
130
|
GraphanaLokiLogTarget = __decorate([
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
PerInstanceCheck(),
|
|
132
|
+
Injectable("GraphanaLogTarget"),
|
|
131
133
|
__metadata("design:paramtypes", [Object])
|
|
132
134
|
], GraphanaLokiLogTarget);
|
|
133
|
-
|
|
135
|
+
export { GraphanaLokiLogTarget };
|
|
134
136
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,0CAA0C;AAC1C,qDAAqD;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAkB,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAGL,SAAS,EAET,MAAM,GACP,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,CAAC,MAAM,QAAQ,CAAC;AAwBvB,IAAK,YAIJ;AAJD,WAAK,YAAY;IACf,uDAAQ,CAAA;IACR,qDAAO,CAAA;IACP,+CAAI,CAAA;AACN,CAAC,EAJI,YAAY,KAAZ,YAAY,QAIhB;AAED,sEAAsE;AACtE,wFAAwF;AAGjF,IAAM,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ACJ;AALT,qBAAqB;IAFjC,gBAAgB,EAAE;IAClB,UAAU,CAAC,mBAAmB,CAAC;;GACnB,qBAAqB,CAwIjC;SAxIY,qBAAqB"}
|
package/package.json
CHANGED
|
@@ -1,51 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "2.0.
|
|
3
|
-
"description": "Log lib for all spinejs related libs",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"url": "https://github.com/spinajs/main
|
|
41
|
-
},
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"@spinajs/
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.48",
|
|
3
|
+
"description": "Log lib for all spinejs related libs",
|
|
4
|
+
"exports": "./lib/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=16.11"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "npm run clean && npm run compile",
|
|
12
|
+
"compile": "tsc -b tsconfig.json",
|
|
13
|
+
"rimraf": "./node_modules/rimraf/bin.js",
|
|
14
|
+
"clean": "rimraf lib/ && rimraf tsconfig.tsbuildinfo",
|
|
15
|
+
"test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
|
|
16
|
+
"coverage": "nyc npm run test",
|
|
17
|
+
"build-docs": "rimraf docs && typedoc --options typedoc.json src/",
|
|
18
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
19
|
+
"lint": "eslint -c .eslintrc.cjs --ext .ts src --fix",
|
|
20
|
+
"preversion": "npm run lint",
|
|
21
|
+
"version": "npm run format && git add -A src",
|
|
22
|
+
"postinstall": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/log)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"name": "@spinajs/log-source-graphana-loki",
|
|
27
|
+
"homepage": "https://github.com/spinajs/main#readme",
|
|
28
|
+
"directories": {
|
|
29
|
+
"lib": "lib",
|
|
30
|
+
"test": "__tests__"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"lib"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/spinajs/main.git"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/spinajs/main/issues"
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "002dc553b0ffffd72193d0121ac425a4083bc9ee",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@spinajs/configuration-common": "^2.0.46",
|
|
48
|
+
"@spinajs/di": "^2.0.46",
|
|
49
|
+
"@spinajs/log": "^2.0.46",
|
|
50
|
+
"axios": "^1.2.3",
|
|
51
|
+
"lodash": "^4.17.21"
|
|
52
|
+
}
|
|
53
|
+
}
|