@logtape/syslog 0.12.0-dev.199
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 +20 -0
- package/README.md +89 -0
- package/deno.json +34 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/mod.cjs +3 -0
- package/dist/mod.d.cts +2 -0
- package/dist/mod.d.ts +2 -0
- package/dist/mod.js +3 -0
- package/dist/syslog.cjs +468 -0
- package/dist/syslog.d.cts +173 -0
- package/dist/syslog.d.cts.map +1 -0
- package/dist/syslog.d.ts +173 -0
- package/dist/syslog.d.ts.map +1 -0
- package/dist/syslog.js +468 -0
- package/dist/syslog.js.map +1 -0
- package/mod.ts +15 -0
- package/package.json +61 -0
- package/syslog.test.ts +1475 -0
- package/syslog.ts +734 -0
- package/tsdown.config.ts +11 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Sink } from "@logtape/logtape";
|
|
2
|
+
|
|
3
|
+
//#region syslog.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Syslog protocol type.
|
|
7
|
+
* @since 0.12.0
|
|
8
|
+
*/
|
|
9
|
+
type SyslogProtocol = "udp" | "tcp";
|
|
10
|
+
/**
|
|
11
|
+
* Syslog facility codes as defined in RFC 5424.
|
|
12
|
+
* @since 0.12.0
|
|
13
|
+
*/
|
|
14
|
+
type SyslogFacility = "kernel" | "user" | "mail" | "daemon" | "security" | "syslog" | "lpr" | "news" | "uucp" | "cron" | "authpriv" | "ftp" | "ntp" | "logaudit" | "logalert" | "clock" | "local0" | "local1" | "local2" | "local3" | "local4" | "local5" | "local6" | "local7";
|
|
15
|
+
/**
|
|
16
|
+
* Options for the syslog sink.
|
|
17
|
+
* @since 0.12.0
|
|
18
|
+
*/
|
|
19
|
+
interface SyslogSinkOptions {
|
|
20
|
+
/**
|
|
21
|
+
* The hostname or IP address of the syslog server.
|
|
22
|
+
* @default "localhost"
|
|
23
|
+
*/
|
|
24
|
+
readonly hostname?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The port number of the syslog server.
|
|
27
|
+
* @default 514
|
|
28
|
+
*/
|
|
29
|
+
readonly port?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The protocol to use for sending syslog messages.
|
|
32
|
+
* @default "udp"
|
|
33
|
+
*/
|
|
34
|
+
readonly protocol?: SyslogProtocol;
|
|
35
|
+
/**
|
|
36
|
+
* The syslog facility to use for all messages.
|
|
37
|
+
* @default "local0"
|
|
38
|
+
*/
|
|
39
|
+
readonly facility?: SyslogFacility;
|
|
40
|
+
/**
|
|
41
|
+
* The application name to include in syslog messages.
|
|
42
|
+
* @default "logtape"
|
|
43
|
+
*/
|
|
44
|
+
readonly appName?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The hostname to include in syslog messages.
|
|
47
|
+
* If not provided, the system hostname will be used.
|
|
48
|
+
*/
|
|
49
|
+
readonly syslogHostname?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The process ID to include in syslog messages.
|
|
52
|
+
* If not provided, the current process ID will be used.
|
|
53
|
+
*/
|
|
54
|
+
readonly processId?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Connection timeout in milliseconds.
|
|
57
|
+
* @default 5000
|
|
58
|
+
*/
|
|
59
|
+
readonly timeout?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to include structured data in syslog messages.
|
|
62
|
+
* @default `false`
|
|
63
|
+
*/
|
|
64
|
+
readonly includeStructuredData?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The structured data ID to use for log properties.
|
|
67
|
+
* Should follow the format "name@private-enterprise-number".
|
|
68
|
+
* @default "logtape@32473"
|
|
69
|
+
*/
|
|
70
|
+
readonly structuredDataId?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Base interface for syslog connections.
|
|
74
|
+
* @since 0.12.0
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Creates a syslog sink that sends log messages to a syslog server using the
|
|
79
|
+
* RFC 5424 syslog protocol format.
|
|
80
|
+
*
|
|
81
|
+
* This sink supports both UDP and TCP protocols for reliable log transmission
|
|
82
|
+
* to centralized logging systems. It automatically formats log records according
|
|
83
|
+
* to RFC 5424 specification, including structured data support for log properties.
|
|
84
|
+
*
|
|
85
|
+
* ## Features
|
|
86
|
+
*
|
|
87
|
+
* - **RFC 5424 Compliance**: Full implementation of the RFC 5424 syslog protocol
|
|
88
|
+
* - **Cross-Runtime Support**: Works with Deno, Node.js, Bun, and browsers
|
|
89
|
+
* - **Multiple Protocols**: Supports both UDP (fire-and-forget) and TCP (reliable) delivery
|
|
90
|
+
* - **Structured Data**: Automatically includes log record properties as RFC 5424 structured data
|
|
91
|
+
* - **Facility Support**: All standard syslog facilities (kern, user, mail, daemon, local0-7, etc.)
|
|
92
|
+
* - **Automatic Escaping**: Proper escaping of special characters in structured data values
|
|
93
|
+
* - **Connection Management**: Automatic connection handling with configurable timeouts
|
|
94
|
+
*
|
|
95
|
+
* ## Protocol Differences
|
|
96
|
+
*
|
|
97
|
+
* - **UDP**: Fast, connectionless delivery suitable for high-throughput logging.
|
|
98
|
+
* Messages may be lost during network issues but has minimal performance impact.
|
|
99
|
+
* - **TCP**: Reliable, connection-based delivery that ensures message delivery.
|
|
100
|
+
* Higher overhead but guarantees that log messages reach the server.
|
|
101
|
+
*
|
|
102
|
+
* @param options Configuration options for the syslog sink
|
|
103
|
+
* @returns A sink function that sends log records to the syslog server, implementing AsyncDisposable for proper cleanup
|
|
104
|
+
*
|
|
105
|
+
* @example Basic usage with default options
|
|
106
|
+
* ```typescript
|
|
107
|
+
* import { configure } from "@logtape/logtape";
|
|
108
|
+
* import { getSyslogSink } from "@logtape/syslog";
|
|
109
|
+
*
|
|
110
|
+
* await configure({
|
|
111
|
+
* sinks: {
|
|
112
|
+
* syslog: getSyslogSink(), // Sends to localhost:514 via UDP
|
|
113
|
+
* },
|
|
114
|
+
* loggers: [
|
|
115
|
+
* { category: [], sinks: ["syslog"], lowestLevel: "info" },
|
|
116
|
+
* ],
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @example Custom syslog server configuration
|
|
121
|
+
* ```typescript
|
|
122
|
+
* import { configure } from "@logtape/logtape";
|
|
123
|
+
* import { getSyslogSink } from "@logtape/syslog";
|
|
124
|
+
*
|
|
125
|
+
* await configure({
|
|
126
|
+
* sinks: {
|
|
127
|
+
* syslog: getSyslogSink({
|
|
128
|
+
* hostname: "log-server.example.com",
|
|
129
|
+
* port: 1514,
|
|
130
|
+
* protocol: "tcp",
|
|
131
|
+
* facility: "mail",
|
|
132
|
+
* appName: "my-application",
|
|
133
|
+
* timeout: 10000,
|
|
134
|
+
* }),
|
|
135
|
+
* },
|
|
136
|
+
* loggers: [
|
|
137
|
+
* { category: [], sinks: ["syslog"], lowestLevel: "debug" },
|
|
138
|
+
* ],
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example Using structured data for log properties
|
|
143
|
+
* ```typescript
|
|
144
|
+
* import { configure, getLogger } from "@logtape/logtape";
|
|
145
|
+
* import { getSyslogSink } from "@logtape/syslog";
|
|
146
|
+
*
|
|
147
|
+
* await configure({
|
|
148
|
+
* sinks: {
|
|
149
|
+
* syslog: getSyslogSink({
|
|
150
|
+
* includeStructuredData: true,
|
|
151
|
+
* structuredDataId: "myapp@12345",
|
|
152
|
+
* }),
|
|
153
|
+
* },
|
|
154
|
+
* loggers: [
|
|
155
|
+
* { category: [], sinks: ["syslog"], lowestLevel: "info" },
|
|
156
|
+
* ],
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* const logger = getLogger();
|
|
160
|
+
* // This will include userId and action as structured data
|
|
161
|
+
* logger.info("User action completed", { userId: 123, action: "login" });
|
|
162
|
+
* // Results in: <134>1 2024-01-01T12:00:00.000Z hostname myapp 1234 - [myapp@12345 userId="123" action="login"] User action completed
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @since 0.12.0
|
|
166
|
+
* @see {@link https://tools.ietf.org/html/rfc5424} RFC 5424 - The Syslog Protocol
|
|
167
|
+
* @see {@link SyslogSinkOptions} for detailed configuration options
|
|
168
|
+
*/
|
|
169
|
+
declare function getSyslogSink(options?: SyslogSinkOptions): Sink & AsyncDisposable;
|
|
170
|
+
//# sourceMappingURL=syslog.d.ts.map
|
|
171
|
+
//#endregion
|
|
172
|
+
export { SyslogFacility, SyslogProtocol, SyslogSinkOptions, getSyslogSink };
|
|
173
|
+
//# sourceMappingURL=syslog.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syslog.d.cts","names":[],"sources":["../syslog.ts"],"sourcesContent":[],"mappings":";;;;;;AAUA;AAMA;AA0EiB,KAhFL,cAAA,GAgFsB,KAAA,GAAA,KAAA;;;;AAuBE;AA0iBpB,KA3oBJ,cAAA,GA2oBiB,QAAA,GAAA,MAAA,GAAA,MAAA,GAAA,QAAA,GAAA,UAAA,GAAA,QAAA,GAAA,KAAA,GAAA,MAAA,GAAA,MAAA,GAAA,MAAA,GAAA,UAAA,GAAA,KAAA,GAAA,KAAA,GAAA,UAAA,GAAA,UAAA,GAAA,OAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA;;;;;AAEJ,UAnkBR,iBAAA,CAmkBQ;;;;;;;;;;;;;;;sBAljBH;;;;;sBAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0iBN,aAAA,WACL,oBACR,OAAO"}
|
package/dist/syslog.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Sink } from "@logtape/logtape";
|
|
2
|
+
|
|
3
|
+
//#region syslog.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Syslog protocol type.
|
|
7
|
+
* @since 0.12.0
|
|
8
|
+
*/
|
|
9
|
+
type SyslogProtocol = "udp" | "tcp";
|
|
10
|
+
/**
|
|
11
|
+
* Syslog facility codes as defined in RFC 5424.
|
|
12
|
+
* @since 0.12.0
|
|
13
|
+
*/
|
|
14
|
+
type SyslogFacility = "kernel" | "user" | "mail" | "daemon" | "security" | "syslog" | "lpr" | "news" | "uucp" | "cron" | "authpriv" | "ftp" | "ntp" | "logaudit" | "logalert" | "clock" | "local0" | "local1" | "local2" | "local3" | "local4" | "local5" | "local6" | "local7";
|
|
15
|
+
/**
|
|
16
|
+
* Options for the syslog sink.
|
|
17
|
+
* @since 0.12.0
|
|
18
|
+
*/
|
|
19
|
+
interface SyslogSinkOptions {
|
|
20
|
+
/**
|
|
21
|
+
* The hostname or IP address of the syslog server.
|
|
22
|
+
* @default "localhost"
|
|
23
|
+
*/
|
|
24
|
+
readonly hostname?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The port number of the syslog server.
|
|
27
|
+
* @default 514
|
|
28
|
+
*/
|
|
29
|
+
readonly port?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The protocol to use for sending syslog messages.
|
|
32
|
+
* @default "udp"
|
|
33
|
+
*/
|
|
34
|
+
readonly protocol?: SyslogProtocol;
|
|
35
|
+
/**
|
|
36
|
+
* The syslog facility to use for all messages.
|
|
37
|
+
* @default "local0"
|
|
38
|
+
*/
|
|
39
|
+
readonly facility?: SyslogFacility;
|
|
40
|
+
/**
|
|
41
|
+
* The application name to include in syslog messages.
|
|
42
|
+
* @default "logtape"
|
|
43
|
+
*/
|
|
44
|
+
readonly appName?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The hostname to include in syslog messages.
|
|
47
|
+
* If not provided, the system hostname will be used.
|
|
48
|
+
*/
|
|
49
|
+
readonly syslogHostname?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The process ID to include in syslog messages.
|
|
52
|
+
* If not provided, the current process ID will be used.
|
|
53
|
+
*/
|
|
54
|
+
readonly processId?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Connection timeout in milliseconds.
|
|
57
|
+
* @default 5000
|
|
58
|
+
*/
|
|
59
|
+
readonly timeout?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to include structured data in syslog messages.
|
|
62
|
+
* @default `false`
|
|
63
|
+
*/
|
|
64
|
+
readonly includeStructuredData?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The structured data ID to use for log properties.
|
|
67
|
+
* Should follow the format "name@private-enterprise-number".
|
|
68
|
+
* @default "logtape@32473"
|
|
69
|
+
*/
|
|
70
|
+
readonly structuredDataId?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Base interface for syslog connections.
|
|
74
|
+
* @since 0.12.0
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Creates a syslog sink that sends log messages to a syslog server using the
|
|
79
|
+
* RFC 5424 syslog protocol format.
|
|
80
|
+
*
|
|
81
|
+
* This sink supports both UDP and TCP protocols for reliable log transmission
|
|
82
|
+
* to centralized logging systems. It automatically formats log records according
|
|
83
|
+
* to RFC 5424 specification, including structured data support for log properties.
|
|
84
|
+
*
|
|
85
|
+
* ## Features
|
|
86
|
+
*
|
|
87
|
+
* - **RFC 5424 Compliance**: Full implementation of the RFC 5424 syslog protocol
|
|
88
|
+
* - **Cross-Runtime Support**: Works with Deno, Node.js, Bun, and browsers
|
|
89
|
+
* - **Multiple Protocols**: Supports both UDP (fire-and-forget) and TCP (reliable) delivery
|
|
90
|
+
* - **Structured Data**: Automatically includes log record properties as RFC 5424 structured data
|
|
91
|
+
* - **Facility Support**: All standard syslog facilities (kern, user, mail, daemon, local0-7, etc.)
|
|
92
|
+
* - **Automatic Escaping**: Proper escaping of special characters in structured data values
|
|
93
|
+
* - **Connection Management**: Automatic connection handling with configurable timeouts
|
|
94
|
+
*
|
|
95
|
+
* ## Protocol Differences
|
|
96
|
+
*
|
|
97
|
+
* - **UDP**: Fast, connectionless delivery suitable for high-throughput logging.
|
|
98
|
+
* Messages may be lost during network issues but has minimal performance impact.
|
|
99
|
+
* - **TCP**: Reliable, connection-based delivery that ensures message delivery.
|
|
100
|
+
* Higher overhead but guarantees that log messages reach the server.
|
|
101
|
+
*
|
|
102
|
+
* @param options Configuration options for the syslog sink
|
|
103
|
+
* @returns A sink function that sends log records to the syslog server, implementing AsyncDisposable for proper cleanup
|
|
104
|
+
*
|
|
105
|
+
* @example Basic usage with default options
|
|
106
|
+
* ```typescript
|
|
107
|
+
* import { configure } from "@logtape/logtape";
|
|
108
|
+
* import { getSyslogSink } from "@logtape/syslog";
|
|
109
|
+
*
|
|
110
|
+
* await configure({
|
|
111
|
+
* sinks: {
|
|
112
|
+
* syslog: getSyslogSink(), // Sends to localhost:514 via UDP
|
|
113
|
+
* },
|
|
114
|
+
* loggers: [
|
|
115
|
+
* { category: [], sinks: ["syslog"], lowestLevel: "info" },
|
|
116
|
+
* ],
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @example Custom syslog server configuration
|
|
121
|
+
* ```typescript
|
|
122
|
+
* import { configure } from "@logtape/logtape";
|
|
123
|
+
* import { getSyslogSink } from "@logtape/syslog";
|
|
124
|
+
*
|
|
125
|
+
* await configure({
|
|
126
|
+
* sinks: {
|
|
127
|
+
* syslog: getSyslogSink({
|
|
128
|
+
* hostname: "log-server.example.com",
|
|
129
|
+
* port: 1514,
|
|
130
|
+
* protocol: "tcp",
|
|
131
|
+
* facility: "mail",
|
|
132
|
+
* appName: "my-application",
|
|
133
|
+
* timeout: 10000,
|
|
134
|
+
* }),
|
|
135
|
+
* },
|
|
136
|
+
* loggers: [
|
|
137
|
+
* { category: [], sinks: ["syslog"], lowestLevel: "debug" },
|
|
138
|
+
* ],
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example Using structured data for log properties
|
|
143
|
+
* ```typescript
|
|
144
|
+
* import { configure, getLogger } from "@logtape/logtape";
|
|
145
|
+
* import { getSyslogSink } from "@logtape/syslog";
|
|
146
|
+
*
|
|
147
|
+
* await configure({
|
|
148
|
+
* sinks: {
|
|
149
|
+
* syslog: getSyslogSink({
|
|
150
|
+
* includeStructuredData: true,
|
|
151
|
+
* structuredDataId: "myapp@12345",
|
|
152
|
+
* }),
|
|
153
|
+
* },
|
|
154
|
+
* loggers: [
|
|
155
|
+
* { category: [], sinks: ["syslog"], lowestLevel: "info" },
|
|
156
|
+
* ],
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* const logger = getLogger();
|
|
160
|
+
* // This will include userId and action as structured data
|
|
161
|
+
* logger.info("User action completed", { userId: 123, action: "login" });
|
|
162
|
+
* // Results in: <134>1 2024-01-01T12:00:00.000Z hostname myapp 1234 - [myapp@12345 userId="123" action="login"] User action completed
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @since 0.12.0
|
|
166
|
+
* @see {@link https://tools.ietf.org/html/rfc5424} RFC 5424 - The Syslog Protocol
|
|
167
|
+
* @see {@link SyslogSinkOptions} for detailed configuration options
|
|
168
|
+
*/
|
|
169
|
+
declare function getSyslogSink(options?: SyslogSinkOptions): Sink & AsyncDisposable;
|
|
170
|
+
//# sourceMappingURL=syslog.d.ts.map
|
|
171
|
+
//#endregion
|
|
172
|
+
export { SyslogFacility, SyslogProtocol, SyslogSinkOptions, getSyslogSink };
|
|
173
|
+
//# sourceMappingURL=syslog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syslog.d.ts","names":[],"sources":["../syslog.ts"],"sourcesContent":[],"mappings":";;;;;;AAUA;AAMA;AA0EiB,KAhFL,cAAA,GAgFsB,KAAA,GAAA,KAAA;;;;AAuBE;AA0iBpB,KA3oBJ,cAAA,GA2oBiB,QAAA,GAAA,MAAA,GAAA,MAAA,GAAA,QAAA,GAAA,UAAA,GAAA,QAAA,GAAA,KAAA,GAAA,MAAA,GAAA,MAAA,GAAA,MAAA,GAAA,UAAA,GAAA,KAAA,GAAA,KAAA,GAAA,UAAA,GAAA,UAAA,GAAA,OAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA,GAAA,QAAA;;;;;AAEJ,UAnkBR,iBAAA,CAmkBQ;;;;;;;;;;;;;;;sBAljBH;;;;;sBAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0iBN,aAAA,WACL,oBACR,OAAO"}
|