@loggerjs/node 0.0.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/cli-integration.d.ts +25 -0
  4. package/dist/cli-integration.d.ts.map +1 -0
  5. package/dist/context.d.ts +9 -0
  6. package/dist/context.d.ts.map +1 -0
  7. package/dist/database-integration.d.ts +34 -0
  8. package/dist/database-integration.d.ts.map +1 -0
  9. package/dist/diagnostics-channel-integration.d.ts +12 -0
  10. package/dist/diagnostics-channel-integration.d.ts.map +1 -0
  11. package/dist/express-integration.d.ts +47 -0
  12. package/dist/express-integration.d.ts.map +1 -0
  13. package/dist/fastify-integration.d.ts +44 -0
  14. package/dist/fastify-integration.d.ts.map +1 -0
  15. package/dist/file-transport.d.ts +15 -0
  16. package/dist/file-transport.d.ts.map +1 -0
  17. package/dist/http-transport.d.ts +12 -0
  18. package/dist/http-transport.d.ts.map +1 -0
  19. package/dist/index.cjs +1757 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.ts +19 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +1730 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/internal-types.d.ts +6 -0
  26. package/dist/internal-types.d.ts.map +1 -0
  27. package/dist/node-fetch-integration.d.ts +42 -0
  28. package/dist/node-fetch-integration.d.ts.map +1 -0
  29. package/dist/node-http-client-integration.d.ts +39 -0
  30. package/dist/node-http-client-integration.d.ts.map +1 -0
  31. package/dist/process-integration.d.ts +13 -0
  32. package/dist/process-integration.d.ts.map +1 -0
  33. package/dist/queue-integration.d.ts +40 -0
  34. package/dist/queue-integration.d.ts.map +1 -0
  35. package/dist/rotating-file-transport.d.ts +18 -0
  36. package/dist/rotating-file-transport.d.ts.map +1 -0
  37. package/dist/serverless-integration.d.ts +50 -0
  38. package/dist/serverless-integration.d.ts.map +1 -0
  39. package/dist/stdout-transport.d.ts +11 -0
  40. package/dist/stdout-transport.d.ts.map +1 -0
  41. package/dist/syslog-transport.d.ts +47 -0
  42. package/dist/syslog-transport.d.ts.map +1 -0
  43. package/dist/worker-transport.d.ts +27 -0
  44. package/dist/worker-transport.d.ts.map +1 -0
  45. package/package.json +132 -0
@@ -0,0 +1,47 @@
1
+ import { type LogEvent, type LoggerLevel, type Transport } from "@loggerjs/core";
2
+ export type NodeSyslogProtocol = "tcp" | "udp4" | "udp6";
3
+ export type NodeSyslogTcpFraming = "newline" | "octet-counting";
4
+ export interface NodeSyslogUdpSocket {
5
+ send: (message: string | Uint8Array, port: number, host: string, callback?: (error: Error | null | undefined) => void) => void;
6
+ close?: () => void;
7
+ on?: (event: "error", listener: (error: Error) => void) => void;
8
+ unref?: () => void;
9
+ }
10
+ export interface NodeSyslogTcpSocket {
11
+ write: (message: string | Uint8Array, callback?: (error?: Error | null) => void) => boolean;
12
+ end?: () => void;
13
+ destroy?: () => void;
14
+ on?: (event: "error", listener: (error: Error) => void) => void;
15
+ unref?: () => void;
16
+ }
17
+ export type NodeSyslogUdpSocketFactory = (protocol: "udp4" | "udp6") => NodeSyslogUdpSocket;
18
+ export type NodeSyslogTcpSocketFactory = (options: {
19
+ host: string;
20
+ port: number;
21
+ }) => NodeSyslogTcpSocket;
22
+ export interface NodeSyslogFormatOptions {
23
+ facility?: number;
24
+ hostname?: string;
25
+ appName?: string | ((event: LogEvent) => string);
26
+ procId?: string | number | ((event: LogEvent) => string | number);
27
+ msgId?: string | ((event: LogEvent) => string);
28
+ structuredData?: string | ((event: LogEvent) => string);
29
+ formatMessage?: (event: LogEvent) => string;
30
+ }
31
+ export interface NodeSyslogTransportOptions extends NodeSyslogFormatOptions {
32
+ name?: string;
33
+ minLevel?: LoggerLevel;
34
+ protocol?: NodeSyslogProtocol;
35
+ host?: string;
36
+ port?: number;
37
+ tcpFraming?: NodeSyslogTcpFraming;
38
+ unref?: boolean;
39
+ udpSocketFactory?: NodeSyslogUdpSocketFactory;
40
+ tcpSocketFactory?: NodeSyslogTcpSocketFactory;
41
+ onError?: (error: unknown, detail: {
42
+ operation: string;
43
+ }) => void;
44
+ }
45
+ export declare function formatSyslogMessage(event: LogEvent, options?: NodeSyslogFormatOptions): string;
46
+ export declare function nodeSyslogTransport(options?: NodeSyslogTransportOptions): Transport;
47
+ //# sourceMappingURL=syslog-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syslog-transport.d.ts","sourceRoot":"","sources":["../src/syslog-transport.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,SAAS,EAEf,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AACzD,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,gBAAgB,CAAC;AAEhE,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,CACJ,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,KACjD,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;IAChE,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,KAAK,OAAO,CAAC;IAC5F,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,OAAO,CAAC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AE,oBAAoB,CAAC;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAC9C,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACnE;AAmDD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,QAAQ,EACf,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAYR;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B,GAAG,SAAS,CAuFvF"}
@@ -0,0 +1,27 @@
1
+ import { type Codec, type LoggerLevel, type Transport } from "@loggerjs/core";
2
+ export interface WorkerLike {
3
+ postMessage: (value: unknown, transferList?: ArrayBuffer[]) => void;
4
+ terminate?: () => void | number | Promise<number>;
5
+ on?: (event: "error" | "exit", listener: (...args: unknown[]) => void) => unknown;
6
+ off?: (event: "error" | "exit", listener: (...args: unknown[]) => void) => unknown;
7
+ }
8
+ export interface WorkerTransportMessage {
9
+ type: "loggerjs:batch";
10
+ codec: string;
11
+ contentType: string;
12
+ count: number;
13
+ payload: Uint8Array;
14
+ }
15
+ export interface WorkerTransportOptions {
16
+ name?: string;
17
+ worker?: WorkerLike;
18
+ workerFactory?: () => WorkerLike;
19
+ workerScript?: string | URL;
20
+ workerOptions?: object;
21
+ fallback?: Transport;
22
+ codec?: Codec<string | Uint8Array>;
23
+ minLevel?: LoggerLevel;
24
+ transferBuffers?: boolean;
25
+ }
26
+ export declare function workerTransport(options?: WorkerTransportOptions): Transport;
27
+ //# sourceMappingURL=worker-transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-transport.d.ts","sourceRoot":"","sources":["../src/worker-transport.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,KAAK,EAEV,KAAK,WAAW,EAChB,KAAK,SAAS,EA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": "@loggerjs/node",
3
+ "version": "0.0.1",
4
+ "description": "Node.js transports and integrations for loggerjs.",
5
+ "homepage": "https://github.com/jskits/loggerjs/tree/main/packages/node#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/jskits/loggerjs/issues"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/jskits/loggerjs.git",
13
+ "directory": "packages/node"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": false,
22
+ "main": "./dist/index.cjs",
23
+ "module": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js",
29
+ "require": "./dist/index.cjs"
30
+ },
31
+ "./transport-http": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.cjs"
35
+ },
36
+ "./transport-file": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.js",
39
+ "require": "./dist/index.cjs"
40
+ },
41
+ "./transport-rotating-file": {
42
+ "types": "./dist/index.d.ts",
43
+ "import": "./dist/index.js",
44
+ "require": "./dist/index.cjs"
45
+ },
46
+ "./transport-stdout": {
47
+ "types": "./dist/index.d.ts",
48
+ "import": "./dist/index.js",
49
+ "require": "./dist/index.cjs"
50
+ },
51
+ "./transport-syslog": {
52
+ "types": "./dist/index.d.ts",
53
+ "import": "./dist/index.js",
54
+ "require": "./dist/index.cjs"
55
+ },
56
+ "./transport-worker": {
57
+ "types": "./dist/index.d.ts",
58
+ "import": "./dist/index.js",
59
+ "require": "./dist/index.cjs"
60
+ },
61
+ "./integration-process": {
62
+ "types": "./dist/index.d.ts",
63
+ "import": "./dist/index.js",
64
+ "require": "./dist/index.cjs"
65
+ },
66
+ "./integration-cli": {
67
+ "types": "./dist/index.d.ts",
68
+ "import": "./dist/index.js",
69
+ "require": "./dist/index.cjs"
70
+ },
71
+ "./integration-queue": {
72
+ "types": "./dist/index.d.ts",
73
+ "import": "./dist/index.js",
74
+ "require": "./dist/index.cjs"
75
+ },
76
+ "./integration-serverless": {
77
+ "types": "./dist/index.d.ts",
78
+ "import": "./dist/index.js",
79
+ "require": "./dist/index.cjs"
80
+ },
81
+ "./integration-database": {
82
+ "types": "./dist/index.d.ts",
83
+ "import": "./dist/index.js",
84
+ "require": "./dist/index.cjs"
85
+ },
86
+ "./integration-express": {
87
+ "types": "./dist/index.d.ts",
88
+ "import": "./dist/index.js",
89
+ "require": "./dist/index.cjs"
90
+ },
91
+ "./integration-fastify": {
92
+ "types": "./dist/index.d.ts",
93
+ "import": "./dist/index.js",
94
+ "require": "./dist/index.cjs"
95
+ },
96
+ "./integration-fetch": {
97
+ "types": "./dist/index.d.ts",
98
+ "import": "./dist/index.js",
99
+ "require": "./dist/index.cjs"
100
+ },
101
+ "./integration-http-client": {
102
+ "types": "./dist/index.d.ts",
103
+ "import": "./dist/index.js",
104
+ "require": "./dist/index.cjs"
105
+ },
106
+ "./integration-diagnostics": {
107
+ "types": "./dist/index.d.ts",
108
+ "import": "./dist/index.js",
109
+ "require": "./dist/index.cjs"
110
+ },
111
+ "./context": {
112
+ "types": "./dist/index.d.ts",
113
+ "import": "./dist/index.js",
114
+ "require": "./dist/index.cjs"
115
+ }
116
+ },
117
+ "publishConfig": {
118
+ "access": "public",
119
+ "provenance": true
120
+ },
121
+ "dependencies": {
122
+ "@loggerjs/core": "0.0.1"
123
+ },
124
+ "scripts": {
125
+ "build": "pnpm run clean && pnpm run build:js && pnpm run build:types",
126
+ "build:js": "rolldown -c ../../rolldown.config.mjs",
127
+ "build:types": "tsc -p tsconfig.build.json && node ../../scripts/fix-dts-extensions.mjs dist",
128
+ "typecheck": "tsc --noEmit -p tsconfig.json",
129
+ "test": "vitest run --passWithNoTests",
130
+ "clean": "rm -rf dist"
131
+ }
132
+ }