@easyoref/monitoring 1.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +14 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +45 -0
- package/dist/logger.js.map +1 -0
- package/package.json +21 -0
- package/src/index.ts +1 -0
- package/src/logger.ts +55 -0
- package/tsconfig.json +9 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EasyOref Logger
|
|
3
|
+
*
|
|
4
|
+
* Dual-output: console (always) + Better Stack Logtail (if token set).
|
|
5
|
+
* Token source: config.yaml `observability.betterstack_token` or LOGTAIL_TOKEN env.
|
|
6
|
+
* Live Tail: https://logs.betterstack.com → your source → "Live Tail"
|
|
7
|
+
*/
|
|
8
|
+
export declare function info(message: string, ctx?: Record<string, unknown>): void;
|
|
9
|
+
export declare function warn(message: string, ctx?: Record<string, unknown>): void;
|
|
10
|
+
export declare function error(message: string, ctx?: Record<string, unknown>): void;
|
|
11
|
+
export declare function debug(message: string, ctx?: Record<string, unknown>): void;
|
|
12
|
+
/** Call before process.exit() — flushes Logtail buffer */
|
|
13
|
+
export declare function flush(): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuBH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAGzE;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAGzE;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAG1E;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAK1E;AAED,0DAA0D;AAC1D,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3C"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EasyOref Logger
|
|
3
|
+
*
|
|
4
|
+
* Dual-output: console (always) + Better Stack Logtail (if token set).
|
|
5
|
+
* Token source: config.yaml `observability.betterstack_token` or LOGTAIL_TOKEN env.
|
|
6
|
+
* Live Tail: https://logs.betterstack.com → your source → "Live Tail"
|
|
7
|
+
*/
|
|
8
|
+
import { Logtail } from "@logtail/node";
|
|
9
|
+
import { config } from "@easyoref/shared";
|
|
10
|
+
const token = config.logtailToken;
|
|
11
|
+
const logtail = token ? new Logtail(token) : null;
|
|
12
|
+
const base = {
|
|
13
|
+
service: "easyoref",
|
|
14
|
+
env: process.env.NODE_ENV ?? "production",
|
|
15
|
+
};
|
|
16
|
+
if (logtail) {
|
|
17
|
+
console.log("📡 Better Stack Logtail enabled — live tail at logs.betterstack.com");
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log("📟 LOGTAIL_TOKEN not set — logging to console only");
|
|
21
|
+
}
|
|
22
|
+
// ── Public API ────────────────────────────────────────────────────────────────
|
|
23
|
+
export function info(message, ctx) {
|
|
24
|
+
console.log(message, ctx ?? "");
|
|
25
|
+
logtail?.info(message, { ...base, ...ctx });
|
|
26
|
+
}
|
|
27
|
+
export function warn(message, ctx) {
|
|
28
|
+
console.warn(message, ctx ?? "");
|
|
29
|
+
logtail?.warn(message, { ...base, ...ctx });
|
|
30
|
+
}
|
|
31
|
+
export function error(message, ctx) {
|
|
32
|
+
console.error(message, ctx ?? "");
|
|
33
|
+
logtail?.error(message, { ...base, ...ctx });
|
|
34
|
+
}
|
|
35
|
+
export function debug(message, ctx) {
|
|
36
|
+
if (process.env.LOG_LEVEL === "debug") {
|
|
37
|
+
console.debug(message, ctx ?? "");
|
|
38
|
+
}
|
|
39
|
+
logtail?.debug(message, { ...base, ...ctx });
|
|
40
|
+
}
|
|
41
|
+
/** Call before process.exit() — flushes Logtail buffer */
|
|
42
|
+
export async function flush() {
|
|
43
|
+
await logtail?.flush();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC;AAClC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAElD,MAAM,IAAI,GAAG;IACX,OAAO,EAAE,UAAU;IACnB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,YAAY;CAC1C,CAAC;AAEF,IAAI,OAA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AE,KAAK,EAAE,CAAC;AACzB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@easyoref/monitoring",
|
|
3
|
+
"version": "1.21.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"typecheck": "tsc --noEmit"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@logtail/node": "^0.5.6",
|
|
13
|
+
"chalk": "^5.3.0",
|
|
14
|
+
"@easyoref/shared": "*",
|
|
15
|
+
"zod": "4.3.6"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.0.0",
|
|
19
|
+
"typescript": "^5.7.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./logger.js";
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EasyOref Logger
|
|
3
|
+
*
|
|
4
|
+
* Dual-output: console (always) + Better Stack Logtail (if token set).
|
|
5
|
+
* Token source: config.yaml `observability.betterstack_token` or LOGTAIL_TOKEN env.
|
|
6
|
+
* Live Tail: https://logs.betterstack.com → your source → "Live Tail"
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Logtail } from "@logtail/node";
|
|
10
|
+
import { config } from "@easyoref/shared";
|
|
11
|
+
|
|
12
|
+
const token = config.logtailToken;
|
|
13
|
+
const logtail = token ? new Logtail(token) : null;
|
|
14
|
+
|
|
15
|
+
const base = {
|
|
16
|
+
service: "easyoref",
|
|
17
|
+
env: process.env.NODE_ENV ?? "production",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
if (logtail) {
|
|
21
|
+
console.log(
|
|
22
|
+
"📡 Better Stack Logtail enabled — live tail at logs.betterstack.com",
|
|
23
|
+
);
|
|
24
|
+
} else {
|
|
25
|
+
console.log("📟 LOGTAIL_TOKEN not set — logging to console only");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ── Public API ────────────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
export function info(message: string, ctx?: Record<string, unknown>): void {
|
|
31
|
+
console.log(message, ctx ?? "");
|
|
32
|
+
logtail?.info(message, { ...base, ...ctx });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function warn(message: string, ctx?: Record<string, unknown>): void {
|
|
36
|
+
console.warn(message, ctx ?? "");
|
|
37
|
+
logtail?.warn(message, { ...base, ...ctx });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function error(message: string, ctx?: Record<string, unknown>): void {
|
|
41
|
+
console.error(message, ctx ?? "");
|
|
42
|
+
logtail?.error(message, { ...base, ...ctx });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function debug(message: string, ctx?: Record<string, unknown>): void {
|
|
46
|
+
if (process.env.LOG_LEVEL === "debug") {
|
|
47
|
+
console.debug(message, ctx ?? "");
|
|
48
|
+
}
|
|
49
|
+
logtail?.debug(message, { ...base, ...ctx });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Call before process.exit() — flushes Logtail buffer */
|
|
53
|
+
export async function flush(): Promise<void> {
|
|
54
|
+
await logtail?.flush();
|
|
55
|
+
}
|