@logtape/windows-eventlog 1.0.0-dev.225 → 1.0.0-dev.229
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 +5 -1
- package/dist/mod.d.cts +2 -2
- package/dist/mod.d.ts +2 -2
- package/dist/sink.bun.cjs +2 -3
- package/dist/sink.bun.d.cts +1 -2
- package/dist/sink.bun.d.cts.map +1 -1
- package/dist/sink.bun.d.ts +1 -2
- package/dist/sink.bun.d.ts.map +1 -1
- package/dist/sink.bun.js +2 -3
- package/dist/sink.bun.js.map +1 -1
- package/dist/sink.deno.cjs +2 -3
- package/dist/sink.deno.d.cts +1 -2
- package/dist/sink.deno.d.cts.map +1 -1
- package/dist/sink.deno.d.ts +1 -2
- package/dist/sink.deno.d.ts.map +1 -1
- package/dist/sink.deno.js +2 -3
- package/dist/sink.deno.js.map +1 -1
- package/dist/sink.node.cjs +2 -3
- package/dist/sink.node.d.cts +1 -2
- package/dist/sink.node.d.cts.map +1 -1
- package/dist/sink.node.d.ts +1 -2
- package/dist/sink.node.d.ts.map +1 -1
- package/dist/sink.node.js +2 -3
- package/dist/sink.node.js.map +1 -1
- package/dist/types.d.cts +1 -15
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +1 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -82,7 +82,6 @@ await configure({
|
|
|
82
82
|
sinks: {
|
|
83
83
|
eventlog: getWindowsEventLogSink({
|
|
84
84
|
sourceName: "MyApplication",
|
|
85
|
-
logName: "Application", // Default log name
|
|
86
85
|
eventIdMapping: {
|
|
87
86
|
error: 1001,
|
|
88
87
|
warning: 2001,
|
|
@@ -96,6 +95,11 @@ await configure({
|
|
|
96
95
|
});
|
|
97
96
|
~~~~
|
|
98
97
|
|
|
98
|
+
> [!NOTE]
|
|
99
|
+
> The Windows Event Log sink always writes to the `Application` log.
|
|
100
|
+
> This is the standard location for application events and does not require
|
|
101
|
+
> administrator privileges.
|
|
102
|
+
|
|
99
103
|
|
|
100
104
|
Runtime support
|
|
101
105
|
---------------
|
package/dist/mod.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { WindowsEventLogError, WindowsEventLogSinkOptions,
|
|
1
|
+
import { WindowsEventLogError, WindowsEventLogSinkOptions, WindowsPlatformError } from "./types.cjs";
|
|
2
2
|
import { getWindowsEventLogSink } from "#wineventlog";
|
|
3
|
-
export { WindowsEventLogError, WindowsEventLogSinkOptions,
|
|
3
|
+
export { WindowsEventLogError, WindowsEventLogSinkOptions, WindowsPlatformError, getWindowsEventLogSink };
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { WindowsEventLogError, WindowsEventLogSinkOptions,
|
|
1
|
+
import { WindowsEventLogError, WindowsEventLogSinkOptions, WindowsPlatformError } from "./types.js";
|
|
2
2
|
import { getWindowsEventLogSink } from "#wineventlog";
|
|
3
|
-
export { WindowsEventLogError, WindowsEventLogSinkOptions,
|
|
3
|
+
export { WindowsEventLogError, WindowsEventLogSinkOptions, WindowsPlatformError, getWindowsEventLogSink };
|
package/dist/sink.bun.cjs
CHANGED
|
@@ -47,8 +47,7 @@ function formatContext(record) {
|
|
|
47
47
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
48
48
|
*
|
|
49
49
|
* const sink = getWindowsEventLogSink({
|
|
50
|
-
* sourceName: "MyApp"
|
|
51
|
-
* logName: "Application"
|
|
50
|
+
* sourceName: "MyApp"
|
|
52
51
|
* });
|
|
53
52
|
* ```
|
|
54
53
|
*
|
|
@@ -56,7 +55,7 @@ function formatContext(record) {
|
|
|
56
55
|
*/
|
|
57
56
|
function getWindowsEventLogSink(options) {
|
|
58
57
|
require_platform.validateWindowsPlatform();
|
|
59
|
-
const { sourceName,
|
|
58
|
+
const { sourceName, eventIdMapping = {} } = options;
|
|
60
59
|
const eventIds = {
|
|
61
60
|
...require_types.DEFAULT_EVENT_ID_MAPPING,
|
|
62
61
|
...eventIdMapping
|
package/dist/sink.bun.d.cts
CHANGED
|
@@ -20,8 +20,7 @@ import { Sink } from "@logtape/logtape";
|
|
|
20
20
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
21
21
|
*
|
|
22
22
|
* const sink = getWindowsEventLogSink({
|
|
23
|
-
* sourceName: "MyApp"
|
|
24
|
-
* logName: "Application"
|
|
23
|
+
* sourceName: "MyApp"
|
|
25
24
|
* });
|
|
26
25
|
* ```
|
|
27
26
|
*
|
package/dist/sink.bun.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.bun.d.cts","names":[],"sources":["../sink.bun.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"sink.bun.d.cts","names":[],"sources":["../sink.bun.ts"],"sourcesContent":[],"mappings":";;;;;;;AA+EA;;;;;AAEoB;;;;;;;;;;;;;;;;iBAFJ,sBAAA,UACL,6BACR,OAAO"}
|
package/dist/sink.bun.d.ts
CHANGED
|
@@ -20,8 +20,7 @@ import { Sink } from "@logtape/logtape";
|
|
|
20
20
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
21
21
|
*
|
|
22
22
|
* const sink = getWindowsEventLogSink({
|
|
23
|
-
* sourceName: "MyApp"
|
|
24
|
-
* logName: "Application"
|
|
23
|
+
* sourceName: "MyApp"
|
|
25
24
|
* });
|
|
26
25
|
* ```
|
|
27
26
|
*
|
package/dist/sink.bun.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.bun.d.ts","names":[],"sources":["../sink.bun.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"sink.bun.d.ts","names":[],"sources":["../sink.bun.ts"],"sourcesContent":[],"mappings":";;;;;;;AA+EA;;;;;AAEoB;;;;;;;;;;;;;;;;iBAFJ,sBAAA,UACL,6BACR,OAAO"}
|
package/dist/sink.bun.js
CHANGED
|
@@ -46,8 +46,7 @@ function formatContext(record) {
|
|
|
46
46
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
47
47
|
*
|
|
48
48
|
* const sink = getWindowsEventLogSink({
|
|
49
|
-
* sourceName: "MyApp"
|
|
50
|
-
* logName: "Application"
|
|
49
|
+
* sourceName: "MyApp"
|
|
51
50
|
* });
|
|
52
51
|
* ```
|
|
53
52
|
*
|
|
@@ -55,7 +54,7 @@ function formatContext(record) {
|
|
|
55
54
|
*/
|
|
56
55
|
function getWindowsEventLogSink(options) {
|
|
57
56
|
validateWindowsPlatform();
|
|
58
|
-
const { sourceName,
|
|
57
|
+
const { sourceName, eventIdMapping = {} } = options;
|
|
59
58
|
const eventIds = {
|
|
60
59
|
...DEFAULT_EVENT_ID_MAPPING,
|
|
61
60
|
...eventIdMapping
|
package/dist/sink.bun.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.bun.js","names":["record: LogRecord","context: string[]","options: WindowsEventLogSinkOptions","ffi: WindowsEventLogFFI | null","sink: Sink & Disposable"],"sources":["../sink.bun.ts"],"sourcesContent":["import type { LogRecord, Sink } from \"@logtape/logtape\";\nimport { getLogger } from \"@logtape/logtape\";\nimport type { WindowsEventLogSinkOptions } from \"./types.ts\";\nimport { DEFAULT_EVENT_ID_MAPPING, mapLogLevelToEventType } from \"./types.ts\";\nimport { validateWindowsPlatform } from \"./platform.ts\";\nimport { WindowsEventLogFFI } from \"./ffi.bun.ts\";\n\n/**\n * Formats a log record message into a string suitable for Windows Event Log.\n * Combines the template and arguments into a readable message.\n */\nfunction formatMessage(record: LogRecord): string {\n let message = \"\";\n\n // Combine template parts with arguments\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n // Template part\n message += record.message[i];\n } else {\n // Argument - serialize it\n const arg = record.message[i];\n if (typeof arg === \"string\") {\n message += arg;\n } else {\n message += JSON.stringify(arg);\n }\n }\n }\n\n return message;\n}\n\n/**\n * Formats additional context information for the log entry.\n * Includes category, properties, and other metadata.\n */\nfunction formatContext(record: LogRecord): string {\n const context: string[] = [];\n\n // Add category if present\n if (record.category && record.category.length > 0) {\n context.push(`Category: ${record.category.join(\".\")}`);\n }\n\n // Add properties if present\n if (record.properties && Object.keys(record.properties).length > 0) {\n context.push(`Properties: ${JSON.stringify(record.properties)}`);\n }\n\n // Add timestamp\n context.push(`Timestamp: ${new Date(record.timestamp).toISOString()}`);\n\n return context.length > 0 ? `\\n\\n${context.join(\"\\n\")}` : \"\";\n}\n\n/**\n * Creates a Windows Event Log sink for Bun environments using FFI.\n *\n * This implementation uses Bun's native Foreign Function Interface to directly\n * call Windows Event Log APIs, providing high performance logging optimized\n * for the Bun runtime.\n *\n * @param options Configuration options for the sink\n * @returns A LogTape sink that writes to Windows Event Log\n * @throws {WindowsPlatformError} If not running on Windows\n * @throws {WindowsEventLogError} If Event Log operations fail\n *\n * @example\n * ```typescript\n * import { getWindowsEventLogSink } from \"@logtape/windows-eventlog\";\n *\n * const sink = getWindowsEventLogSink({\n * sourceName: \"MyApp\"
|
|
1
|
+
{"version":3,"file":"sink.bun.js","names":["record: LogRecord","context: string[]","options: WindowsEventLogSinkOptions","ffi: WindowsEventLogFFI | null","sink: Sink & Disposable"],"sources":["../sink.bun.ts"],"sourcesContent":["import type { LogRecord, Sink } from \"@logtape/logtape\";\nimport { getLogger } from \"@logtape/logtape\";\nimport type { WindowsEventLogSinkOptions } from \"./types.ts\";\nimport { DEFAULT_EVENT_ID_MAPPING, mapLogLevelToEventType } from \"./types.ts\";\nimport { validateWindowsPlatform } from \"./platform.ts\";\nimport { WindowsEventLogFFI } from \"./ffi.bun.ts\";\n\n/**\n * Formats a log record message into a string suitable for Windows Event Log.\n * Combines the template and arguments into a readable message.\n */\nfunction formatMessage(record: LogRecord): string {\n let message = \"\";\n\n // Combine template parts with arguments\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n // Template part\n message += record.message[i];\n } else {\n // Argument - serialize it\n const arg = record.message[i];\n if (typeof arg === \"string\") {\n message += arg;\n } else {\n message += JSON.stringify(arg);\n }\n }\n }\n\n return message;\n}\n\n/**\n * Formats additional context information for the log entry.\n * Includes category, properties, and other metadata.\n */\nfunction formatContext(record: LogRecord): string {\n const context: string[] = [];\n\n // Add category if present\n if (record.category && record.category.length > 0) {\n context.push(`Category: ${record.category.join(\".\")}`);\n }\n\n // Add properties if present\n if (record.properties && Object.keys(record.properties).length > 0) {\n context.push(`Properties: ${JSON.stringify(record.properties)}`);\n }\n\n // Add timestamp\n context.push(`Timestamp: ${new Date(record.timestamp).toISOString()}`);\n\n return context.length > 0 ? `\\n\\n${context.join(\"\\n\")}` : \"\";\n}\n\n/**\n * Creates a Windows Event Log sink for Bun environments using FFI.\n *\n * This implementation uses Bun's native Foreign Function Interface to directly\n * call Windows Event Log APIs, providing high performance logging optimized\n * for the Bun runtime.\n *\n * @param options Configuration options for the sink\n * @returns A LogTape sink that writes to Windows Event Log\n * @throws {WindowsPlatformError} If not running on Windows\n * @throws {WindowsEventLogError} If Event Log operations fail\n *\n * @example\n * ```typescript\n * import { getWindowsEventLogSink } from \"@logtape/windows-eventlog\";\n *\n * const sink = getWindowsEventLogSink({\n * sourceName: \"MyApp\"\n * });\n * ```\n *\n * @since 1.0.0\n */\nexport function getWindowsEventLogSink(\n options: WindowsEventLogSinkOptions,\n): Sink & Disposable {\n // Validate platform early\n validateWindowsPlatform();\n\n const {\n sourceName,\n eventIdMapping = {},\n } = options;\n\n // Merge with default event ID mapping\n const eventIds = { ...DEFAULT_EVENT_ID_MAPPING, ...eventIdMapping };\n\n let ffi: WindowsEventLogFFI | null = null;\n const metaLogger = getLogger([\"logtape\", \"meta\", \"windows-eventlog\"]);\n\n const sink: Sink & Disposable = (record: LogRecord) => {\n if (!ffi) {\n ffi = new WindowsEventLogFFI(sourceName);\n try {\n ffi.initialize();\n } catch (error) {\n metaLogger.error(\n \"Failed to initialize Windows Event Log FFI: {error}\",\n { error },\n );\n ffi = null; // Reset FFI on error\n return;\n }\n }\n\n // Format the complete message\n const message = formatMessage(record);\n const context = formatContext(record);\n const fullMessage = message + context;\n\n // Get event type and ID for this log level\n const eventType = mapLogLevelToEventType(record.level);\n const eventId = eventIds[record.level];\n\n // Write to Event Log using FFI (synchronously since Bun FFI initializes synchronously)\n if (ffi) {\n try {\n ffi.writeEvent(eventType, eventId, fullMessage);\n } catch (error) {\n metaLogger.error(\n \"Failed to write to Windows Event Log: {error}\",\n { error },\n );\n }\n }\n };\n\n // Implement Disposable for cleanup\n sink[Symbol.dispose] = () => {\n if (ffi) {\n ffi.dispose();\n ffi = null;\n }\n };\n\n return sink;\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAS,cAAcA,QAA2B;CAChD,IAAI,UAAU;AAGd,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,IACzC,KAAI,IAAI,MAAM,EAEZ,YAAW,OAAO,QAAQ;MACrB;EAEL,MAAM,MAAM,OAAO,QAAQ;AAC3B,aAAW,QAAQ,SACjB,YAAW;MAEX,YAAW,KAAK,UAAU,IAAI;CAEjC;AAGH,QAAO;AACR;;;;;AAMD,SAAS,cAAcA,QAA2B;CAChD,MAAMC,UAAoB,CAAE;AAG5B,KAAI,OAAO,YAAY,OAAO,SAAS,SAAS,EAC9C,SAAQ,MAAM,YAAY,OAAO,SAAS,KAAK,IAAI,CAAC,EAAE;AAIxD,KAAI,OAAO,cAAc,OAAO,KAAK,OAAO,WAAW,CAAC,SAAS,EAC/D,SAAQ,MAAM,cAAc,KAAK,UAAU,OAAO,WAAW,CAAC,EAAE;AAIlE,SAAQ,MAAM,aAAa,IAAI,KAAK,OAAO,WAAW,aAAa,CAAC,EAAE;AAEtE,QAAO,QAAQ,SAAS,KAAK,MAAM,QAAQ,KAAK,KAAK,CAAC,IAAI;AAC3D;;;;;;;;;;;;;;;;;;;;;;;;AAyBD,SAAgB,uBACdC,SACmB;AAEnB,0BAAyB;CAEzB,MAAM,EACJ,YACA,iBAAiB,CAAE,GACpB,GAAG;CAGJ,MAAM,WAAW;EAAE,GAAG;EAA0B,GAAG;CAAgB;CAEnE,IAAIC,MAAiC;CACrC,MAAM,aAAa,UAAU;EAAC;EAAW;EAAQ;CAAmB,EAAC;CAErE,MAAMC,OAA0B,CAACJ,WAAsB;AACrD,OAAK,KAAK;AACR,SAAM,IAAI,mBAAmB;AAC7B,OAAI;AACF,QAAI,YAAY;GACjB,SAAQ,OAAO;AACd,eAAW,MACT,uDACA,EAAE,MAAO,EACV;AACD,UAAM;AACN;GACD;EACF;EAGD,MAAM,UAAU,cAAc,OAAO;EACrC,MAAM,UAAU,cAAc,OAAO;EACrC,MAAM,cAAc,UAAU;EAG9B,MAAM,YAAY,uBAAuB,OAAO,MAAM;EACtD,MAAM,UAAU,SAAS,OAAO;AAGhC,MAAI,IACF,KAAI;AACF,OAAI,WAAW,WAAW,SAAS,YAAY;EAChD,SAAQ,OAAO;AACd,cAAW,MACT,iDACA,EAAE,MAAO,EACV;EACF;CAEJ;AAGD,MAAK,OAAO,WAAW,MAAM;AAC3B,MAAI,KAAK;AACP,OAAI,SAAS;AACb,SAAM;EACP;CACF;AAED,QAAO;AACR"}
|
package/dist/sink.deno.cjs
CHANGED
|
@@ -61,8 +61,7 @@ function getEventType(level) {
|
|
|
61
61
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
62
62
|
*
|
|
63
63
|
* const sink = getWindowsEventLogSink({
|
|
64
|
-
* sourceName: "MyApp"
|
|
65
|
-
* logName: "Application"
|
|
64
|
+
* sourceName: "MyApp"
|
|
66
65
|
* });
|
|
67
66
|
* ```
|
|
68
67
|
*
|
|
@@ -70,7 +69,7 @@ function getEventType(level) {
|
|
|
70
69
|
*/
|
|
71
70
|
function getWindowsEventLogSink(options) {
|
|
72
71
|
require_platform.validateWindowsPlatform();
|
|
73
|
-
const { sourceName,
|
|
72
|
+
const { sourceName, eventIdMapping = {} } = options;
|
|
74
73
|
const eventIds = {
|
|
75
74
|
...require_types.DEFAULT_EVENT_ID_MAPPING,
|
|
76
75
|
...eventIdMapping
|
package/dist/sink.deno.d.cts
CHANGED
|
@@ -20,8 +20,7 @@ import { Sink } from "@logtape/logtape";
|
|
|
20
20
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
21
21
|
*
|
|
22
22
|
* const sink = getWindowsEventLogSink({
|
|
23
|
-
* sourceName: "MyApp"
|
|
24
|
-
* logName: "Application"
|
|
23
|
+
* sourceName: "MyApp"
|
|
25
24
|
* });
|
|
26
25
|
* ```
|
|
27
26
|
*
|
package/dist/sink.deno.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.deno.d.cts","names":[],"sources":["../sink.deno.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"sink.deno.d.cts","names":[],"sources":["../sink.deno.ts"],"sourcesContent":[],"mappings":";;;;;;;AAsGA;;;;;AAEoB;;;;;;;;;;;;;;;;iBAFJ,sBAAA,UACL,6BACR,OAAO"}
|
package/dist/sink.deno.d.ts
CHANGED
|
@@ -20,8 +20,7 @@ import { Sink } from "@logtape/logtape";
|
|
|
20
20
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
21
21
|
*
|
|
22
22
|
* const sink = getWindowsEventLogSink({
|
|
23
|
-
* sourceName: "MyApp"
|
|
24
|
-
* logName: "Application"
|
|
23
|
+
* sourceName: "MyApp"
|
|
25
24
|
* });
|
|
26
25
|
* ```
|
|
27
26
|
*
|
package/dist/sink.deno.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.deno.d.ts","names":[],"sources":["../sink.deno.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"sink.deno.d.ts","names":[],"sources":["../sink.deno.ts"],"sourcesContent":[],"mappings":";;;;;;;AAsGA;;;;;AAEoB;;;;;;;;;;;;;;;;iBAFJ,sBAAA,UACL,6BACR,OAAO"}
|
package/dist/sink.deno.js
CHANGED
|
@@ -60,8 +60,7 @@ function getEventType(level) {
|
|
|
60
60
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
61
61
|
*
|
|
62
62
|
* const sink = getWindowsEventLogSink({
|
|
63
|
-
* sourceName: "MyApp"
|
|
64
|
-
* logName: "Application"
|
|
63
|
+
* sourceName: "MyApp"
|
|
65
64
|
* });
|
|
66
65
|
* ```
|
|
67
66
|
*
|
|
@@ -69,7 +68,7 @@ function getEventType(level) {
|
|
|
69
68
|
*/
|
|
70
69
|
function getWindowsEventLogSink(options) {
|
|
71
70
|
validateWindowsPlatform();
|
|
72
|
-
const { sourceName,
|
|
71
|
+
const { sourceName, eventIdMapping = {} } = options;
|
|
73
72
|
const eventIds = {
|
|
74
73
|
...DEFAULT_EVENT_ID_MAPPING,
|
|
75
74
|
...eventIdMapping
|
package/dist/sink.deno.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.deno.js","names":["record: LogRecord","context: string[]","level: string","options: WindowsEventLogSinkOptions","ffi: WindowsEventLogFFI | null","sink: Sink & Disposable"],"sources":["../sink.deno.ts"],"sourcesContent":["import type { LogRecord, Sink } from \"@logtape/logtape\";\nimport { getLogger } from \"@logtape/logtape\";\nimport {\n EVENTLOG_ERROR_TYPE,\n EVENTLOG_INFORMATION_TYPE,\n EVENTLOG_WARNING_TYPE,\n WindowsEventLogFFI,\n} from \"./ffi.deno.ts\";\nimport { validateWindowsPlatform } from \"./platform.ts\";\nimport type { WindowsEventLogSinkOptions } from \"./types.ts\";\nimport { DEFAULT_EVENT_ID_MAPPING } from \"./types.ts\";\n\n/**\n * Formats a log record message into a string suitable for Windows Event Log.\n * Combines the template and arguments into a readable message.\n */\nfunction formatMessage(record: LogRecord): string {\n let message = \"\";\n\n // Combine template parts with arguments\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n // Template part\n message += record.message[i];\n } else {\n // Argument - serialize it\n const arg = record.message[i];\n if (typeof arg === \"string\") {\n message += arg;\n } else {\n message += JSON.stringify(arg);\n }\n }\n }\n\n return message;\n}\n\n/**\n * Formats additional context information for the log entry.\n * Includes category, properties, and other metadata.\n */\nfunction formatContext(record: LogRecord): string {\n const context: string[] = [];\n\n // Add category if present\n if (record.category && record.category.length > 0) {\n context.push(`Category: ${record.category.join(\".\")}`);\n }\n\n // Add properties if present\n if (record.properties && Object.keys(record.properties).length > 0) {\n context.push(`Properties: ${JSON.stringify(record.properties)}`);\n }\n\n // Add timestamp\n context.push(`Timestamp: ${new Date(record.timestamp).toISOString()}`);\n\n return context.length > 0 ? `\\n\\n${context.join(\"\\n\")}` : \"\";\n}\n\n/**\n * Maps LogTape log levels to Windows Event Log types.\n */\nfunction getEventType(level: string): number {\n switch (level) {\n case \"fatal\":\n case \"error\":\n return EVENTLOG_ERROR_TYPE;\n case \"warning\":\n return EVENTLOG_WARNING_TYPE;\n case \"info\":\n case \"debug\":\n case \"trace\":\n default:\n return EVENTLOG_INFORMATION_TYPE;\n }\n}\n\n/**\n * Creates a Windows Event Log sink for Deno environments using FFI.\n *\n * This implementation uses Deno's Foreign Function Interface to directly\n * call Windows Event Log APIs, providing reliable Event Log integration\n * without depending on external packages.\n *\n * @param options Configuration options for the sink\n * @returns A LogTape sink that writes to Windows Event Log\n * @throws {WindowsPlatformError} If not running on Windows\n * @throws {WindowsEventLogError} If Event Log operations fail\n *\n * @example\n * ```typescript\n * import { getWindowsEventLogSink } from \"@logtape/windows-eventlog\";\n *\n * const sink = getWindowsEventLogSink({\n * sourceName: \"MyApp\"
|
|
1
|
+
{"version":3,"file":"sink.deno.js","names":["record: LogRecord","context: string[]","level: string","options: WindowsEventLogSinkOptions","ffi: WindowsEventLogFFI | null","sink: Sink & Disposable"],"sources":["../sink.deno.ts"],"sourcesContent":["import type { LogRecord, Sink } from \"@logtape/logtape\";\nimport { getLogger } from \"@logtape/logtape\";\nimport {\n EVENTLOG_ERROR_TYPE,\n EVENTLOG_INFORMATION_TYPE,\n EVENTLOG_WARNING_TYPE,\n WindowsEventLogFFI,\n} from \"./ffi.deno.ts\";\nimport { validateWindowsPlatform } from \"./platform.ts\";\nimport type { WindowsEventLogSinkOptions } from \"./types.ts\";\nimport { DEFAULT_EVENT_ID_MAPPING } from \"./types.ts\";\n\n/**\n * Formats a log record message into a string suitable for Windows Event Log.\n * Combines the template and arguments into a readable message.\n */\nfunction formatMessage(record: LogRecord): string {\n let message = \"\";\n\n // Combine template parts with arguments\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n // Template part\n message += record.message[i];\n } else {\n // Argument - serialize it\n const arg = record.message[i];\n if (typeof arg === \"string\") {\n message += arg;\n } else {\n message += JSON.stringify(arg);\n }\n }\n }\n\n return message;\n}\n\n/**\n * Formats additional context information for the log entry.\n * Includes category, properties, and other metadata.\n */\nfunction formatContext(record: LogRecord): string {\n const context: string[] = [];\n\n // Add category if present\n if (record.category && record.category.length > 0) {\n context.push(`Category: ${record.category.join(\".\")}`);\n }\n\n // Add properties if present\n if (record.properties && Object.keys(record.properties).length > 0) {\n context.push(`Properties: ${JSON.stringify(record.properties)}`);\n }\n\n // Add timestamp\n context.push(`Timestamp: ${new Date(record.timestamp).toISOString()}`);\n\n return context.length > 0 ? `\\n\\n${context.join(\"\\n\")}` : \"\";\n}\n\n/**\n * Maps LogTape log levels to Windows Event Log types.\n */\nfunction getEventType(level: string): number {\n switch (level) {\n case \"fatal\":\n case \"error\":\n return EVENTLOG_ERROR_TYPE;\n case \"warning\":\n return EVENTLOG_WARNING_TYPE;\n case \"info\":\n case \"debug\":\n case \"trace\":\n default:\n return EVENTLOG_INFORMATION_TYPE;\n }\n}\n\n/**\n * Creates a Windows Event Log sink for Deno environments using FFI.\n *\n * This implementation uses Deno's Foreign Function Interface to directly\n * call Windows Event Log APIs, providing reliable Event Log integration\n * without depending on external packages.\n *\n * @param options Configuration options for the sink\n * @returns A LogTape sink that writes to Windows Event Log\n * @throws {WindowsPlatformError} If not running on Windows\n * @throws {WindowsEventLogError} If Event Log operations fail\n *\n * @example\n * ```typescript\n * import { getWindowsEventLogSink } from \"@logtape/windows-eventlog\";\n *\n * const sink = getWindowsEventLogSink({\n * sourceName: \"MyApp\"\n * });\n * ```\n *\n * @since 1.0.0\n */\nexport function getWindowsEventLogSink(\n options: WindowsEventLogSinkOptions,\n): Sink & Disposable {\n // Validate platform early\n validateWindowsPlatform();\n\n const {\n sourceName,\n eventIdMapping = {},\n } = options;\n\n // Merge with default event ID mapping\n const eventIds = { ...DEFAULT_EVENT_ID_MAPPING, ...eventIdMapping };\n\n let ffi: WindowsEventLogFFI | null = null;\n const metaLogger = getLogger([\"logtape\", \"meta\", \"windows-eventlog\"]);\n\n const sink: Sink & Disposable = (record: LogRecord) => {\n // Initialize FFI if needed\n if (!ffi) {\n try {\n ffi = new WindowsEventLogFFI(sourceName);\n ffi.initialize();\n } catch (error) {\n metaLogger.error(\n \"Failed to initialize Windows Event Log FFI: {error}\",\n { error },\n );\n return; // Skip this log record\n }\n }\n\n // Format the complete message\n const message = formatMessage(record);\n const context = formatContext(record);\n const fullMessage = message + context;\n\n // Get event type and ID for this log level\n const eventType = getEventType(record.level);\n const eventId = eventIds[record.level];\n\n // Write to Event Log\n try {\n ffi.writeEvent(eventType, eventId, fullMessage);\n } catch (error) {\n metaLogger.error(\n \"Failed to write {level} message to Windows Event Log: {error}\",\n { level: record.level, error },\n );\n }\n };\n\n // Implement Disposable for cleanup\n sink[Symbol.dispose] = () => {\n // Clean up FFI resources\n if (ffi) {\n ffi.dispose();\n ffi = null;\n }\n };\n\n return sink;\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAS,cAAcA,QAA2B;CAChD,IAAI,UAAU;AAGd,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,IACzC,KAAI,IAAI,MAAM,EAEZ,YAAW,OAAO,QAAQ;MACrB;EAEL,MAAM,MAAM,OAAO,QAAQ;AAC3B,aAAW,QAAQ,SACjB,YAAW;MAEX,YAAW,KAAK,UAAU,IAAI;CAEjC;AAGH,QAAO;AACR;;;;;AAMD,SAAS,cAAcA,QAA2B;CAChD,MAAMC,UAAoB,CAAE;AAG5B,KAAI,OAAO,YAAY,OAAO,SAAS,SAAS,EAC9C,SAAQ,MAAM,YAAY,OAAO,SAAS,KAAK,IAAI,CAAC,EAAE;AAIxD,KAAI,OAAO,cAAc,OAAO,KAAK,OAAO,WAAW,CAAC,SAAS,EAC/D,SAAQ,MAAM,cAAc,KAAK,UAAU,OAAO,WAAW,CAAC,EAAE;AAIlE,SAAQ,MAAM,aAAa,IAAI,KAAK,OAAO,WAAW,aAAa,CAAC,EAAE;AAEtE,QAAO,QAAQ,SAAS,KAAK,MAAM,QAAQ,KAAK,KAAK,CAAC,IAAI;AAC3D;;;;AAKD,SAAS,aAAaC,OAAuB;AAC3C,SAAQ,OAAR;EACE,KAAK;EACL,KAAK,QACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK;EACL,QACE,QAAO;CACV;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBD,SAAgB,uBACdC,SACmB;AAEnB,0BAAyB;CAEzB,MAAM,EACJ,YACA,iBAAiB,CAAE,GACpB,GAAG;CAGJ,MAAM,WAAW;EAAE,GAAG;EAA0B,GAAG;CAAgB;CAEnE,IAAIC,MAAiC;CACrC,MAAM,aAAa,UAAU;EAAC;EAAW;EAAQ;CAAmB,EAAC;CAErE,MAAMC,OAA0B,CAACL,WAAsB;AAErD,OAAK,IACH,KAAI;AACF,SAAM,IAAI,mBAAmB;AAC7B,OAAI,YAAY;EACjB,SAAQ,OAAO;AACd,cAAW,MACT,uDACA,EAAE,MAAO,EACV;AACD;EACD;EAIH,MAAM,UAAU,cAAc,OAAO;EACrC,MAAM,UAAU,cAAc,OAAO;EACrC,MAAM,cAAc,UAAU;EAG9B,MAAM,YAAY,aAAa,OAAO,MAAM;EAC5C,MAAM,UAAU,SAAS,OAAO;AAGhC,MAAI;AACF,OAAI,WAAW,WAAW,SAAS,YAAY;EAChD,SAAQ,OAAO;AACd,cAAW,MACT,iEACA;IAAE,OAAO,OAAO;IAAO;GAAO,EAC/B;EACF;CACF;AAGD,MAAK,OAAO,WAAW,MAAM;AAE3B,MAAI,KAAK;AACP,OAAI,SAAS;AACb,SAAM;EACP;CACF;AAED,QAAO;AACR"}
|
package/dist/sink.node.cjs
CHANGED
|
@@ -46,8 +46,7 @@ function formatContext(record) {
|
|
|
46
46
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
47
47
|
*
|
|
48
48
|
* const sink = getWindowsEventLogSink({
|
|
49
|
-
* sourceName: "MyApp"
|
|
50
|
-
* logName: "Application"
|
|
49
|
+
* sourceName: "MyApp"
|
|
51
50
|
* });
|
|
52
51
|
* ```
|
|
53
52
|
*
|
|
@@ -55,7 +54,7 @@ function formatContext(record) {
|
|
|
55
54
|
*/
|
|
56
55
|
function getWindowsEventLogSink(options) {
|
|
57
56
|
require_platform.validateWindowsPlatform();
|
|
58
|
-
const { sourceName,
|
|
57
|
+
const { sourceName, eventIdMapping = {} } = options;
|
|
59
58
|
const eventIds = {
|
|
60
59
|
...require_types.DEFAULT_EVENT_ID_MAPPING,
|
|
61
60
|
...eventIdMapping
|
package/dist/sink.node.d.cts
CHANGED
|
@@ -19,8 +19,7 @@ import { Sink } from "@logtape/logtape";
|
|
|
19
19
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
20
20
|
*
|
|
21
21
|
* const sink = getWindowsEventLogSink({
|
|
22
|
-
* sourceName: "MyApp"
|
|
23
|
-
* logName: "Application"
|
|
22
|
+
* sourceName: "MyApp"
|
|
24
23
|
* });
|
|
25
24
|
* ```
|
|
26
25
|
*
|
package/dist/sink.node.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.node.d.cts","names":[],"sources":["../sink.node.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"sink.node.d.cts","names":[],"sources":["../sink.node.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;;;;;AAEoB;;;;;;;;;;;;;;;iBAFJ,sBAAA,UACL,6BACR,OAAO"}
|
package/dist/sink.node.d.ts
CHANGED
|
@@ -19,8 +19,7 @@ import { Sink } from "@logtape/logtape";
|
|
|
19
19
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
20
20
|
*
|
|
21
21
|
* const sink = getWindowsEventLogSink({
|
|
22
|
-
* sourceName: "MyApp"
|
|
23
|
-
* logName: "Application"
|
|
22
|
+
* sourceName: "MyApp"
|
|
24
23
|
* });
|
|
25
24
|
* ```
|
|
26
25
|
*
|
package/dist/sink.node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.node.d.ts","names":[],"sources":["../sink.node.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"sink.node.d.ts","names":[],"sources":["../sink.node.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;;;;;AAEoB;;;;;;;;;;;;;;;iBAFJ,sBAAA,UACL,6BACR,OAAO"}
|
package/dist/sink.node.js
CHANGED
|
@@ -45,8 +45,7 @@ function formatContext(record) {
|
|
|
45
45
|
* import { getWindowsEventLogSink } from "@logtape/windows-eventlog";
|
|
46
46
|
*
|
|
47
47
|
* const sink = getWindowsEventLogSink({
|
|
48
|
-
* sourceName: "MyApp"
|
|
49
|
-
* logName: "Application"
|
|
48
|
+
* sourceName: "MyApp"
|
|
50
49
|
* });
|
|
51
50
|
* ```
|
|
52
51
|
*
|
|
@@ -54,7 +53,7 @@ function formatContext(record) {
|
|
|
54
53
|
*/
|
|
55
54
|
function getWindowsEventLogSink(options) {
|
|
56
55
|
validateWindowsPlatform();
|
|
57
|
-
const { sourceName,
|
|
56
|
+
const { sourceName, eventIdMapping = {} } = options;
|
|
58
57
|
const eventIds = {
|
|
59
58
|
...DEFAULT_EVENT_ID_MAPPING,
|
|
60
59
|
...eventIdMapping
|
package/dist/sink.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.node.js","names":["record: LogRecord","context: string[]","options: WindowsEventLogSinkOptions","ffi: WindowsEventLogFFI | null","initPromise: Promise<void> | null","sink: Sink & Disposable"],"sources":["../sink.node.ts"],"sourcesContent":["import type { LogRecord, Sink } from \"@logtape/logtape\";\nimport { getLogger } from \"@logtape/logtape\";\nimport type { WindowsEventLogSinkOptions } from \"./types.ts\";\nimport {\n DEFAULT_EVENT_ID_MAPPING,\n mapLogLevelToEventType,\n type WindowsEventLogError as _WindowsEventLogError,\n} from \"./types.ts\";\nimport { validateWindowsPlatform } from \"./platform.ts\";\nimport { WindowsEventLogFFI } from \"./ffi.node.ts\";\n\n/**\n * Formats a log record message into a string suitable for Windows Event Log.\n * Combines the template and arguments into a readable message.\n */\nfunction formatMessage(record: LogRecord): string {\n let message = \"\";\n\n // Combine template parts with arguments\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n // Template part\n message += record.message[i];\n } else {\n // Argument - serialize it\n const arg = record.message[i];\n if (typeof arg === \"string\") {\n message += arg;\n } else {\n message += JSON.stringify(arg);\n }\n }\n }\n\n return message;\n}\n\n/**\n * Formats additional context information for the log entry.\n * Includes category, properties, and other metadata.\n */\nfunction formatContext(record: LogRecord): string {\n const context: string[] = [];\n\n // Add category if present\n if (record.category && record.category.length > 0) {\n context.push(`Category: ${record.category.join(\".\")}`);\n }\n\n // Add properties if present\n if (record.properties && Object.keys(record.properties).length > 0) {\n context.push(`Properties: ${JSON.stringify(record.properties)}`);\n }\n\n // Add timestamp\n context.push(`Timestamp: ${new Date(record.timestamp).toISOString()}`);\n\n return context.length > 0 ? `\\n\\n${context.join(\"\\n\")}` : \"\";\n}\n\n/**\n * Creates a Windows Event Log sink for Node.js environments using FFI.\n *\n * This implementation uses koffi to call Windows Event Log API directly,\n * providing high performance logging without external dependencies.\n *\n * @param options Configuration options for the sink\n * @returns A LogTape sink that writes to Windows Event Log\n * @throws {WindowsPlatformError} If not running on Windows\n * @throws {WindowsEventLogError} If Event Log operations fail\n *\n * @example\n * ```typescript\n * import { getWindowsEventLogSink } from \"@logtape/windows-eventlog\";\n *\n * const sink = getWindowsEventLogSink({\n * sourceName: \"MyApp\"
|
|
1
|
+
{"version":3,"file":"sink.node.js","names":["record: LogRecord","context: string[]","options: WindowsEventLogSinkOptions","ffi: WindowsEventLogFFI | null","initPromise: Promise<void> | null","sink: Sink & Disposable"],"sources":["../sink.node.ts"],"sourcesContent":["import type { LogRecord, Sink } from \"@logtape/logtape\";\nimport { getLogger } from \"@logtape/logtape\";\nimport type { WindowsEventLogSinkOptions } from \"./types.ts\";\nimport {\n DEFAULT_EVENT_ID_MAPPING,\n mapLogLevelToEventType,\n type WindowsEventLogError as _WindowsEventLogError,\n} from \"./types.ts\";\nimport { validateWindowsPlatform } from \"./platform.ts\";\nimport { WindowsEventLogFFI } from \"./ffi.node.ts\";\n\n/**\n * Formats a log record message into a string suitable for Windows Event Log.\n * Combines the template and arguments into a readable message.\n */\nfunction formatMessage(record: LogRecord): string {\n let message = \"\";\n\n // Combine template parts with arguments\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n // Template part\n message += record.message[i];\n } else {\n // Argument - serialize it\n const arg = record.message[i];\n if (typeof arg === \"string\") {\n message += arg;\n } else {\n message += JSON.stringify(arg);\n }\n }\n }\n\n return message;\n}\n\n/**\n * Formats additional context information for the log entry.\n * Includes category, properties, and other metadata.\n */\nfunction formatContext(record: LogRecord): string {\n const context: string[] = [];\n\n // Add category if present\n if (record.category && record.category.length > 0) {\n context.push(`Category: ${record.category.join(\".\")}`);\n }\n\n // Add properties if present\n if (record.properties && Object.keys(record.properties).length > 0) {\n context.push(`Properties: ${JSON.stringify(record.properties)}`);\n }\n\n // Add timestamp\n context.push(`Timestamp: ${new Date(record.timestamp).toISOString()}`);\n\n return context.length > 0 ? `\\n\\n${context.join(\"\\n\")}` : \"\";\n}\n\n/**\n * Creates a Windows Event Log sink for Node.js environments using FFI.\n *\n * This implementation uses koffi to call Windows Event Log API directly,\n * providing high performance logging without external dependencies.\n *\n * @param options Configuration options for the sink\n * @returns A LogTape sink that writes to Windows Event Log\n * @throws {WindowsPlatformError} If not running on Windows\n * @throws {WindowsEventLogError} If Event Log operations fail\n *\n * @example\n * ```typescript\n * import { getWindowsEventLogSink } from \"@logtape/windows-eventlog\";\n *\n * const sink = getWindowsEventLogSink({\n * sourceName: \"MyApp\"\n * });\n * ```\n *\n * @since 1.0.0\n */\nexport function getWindowsEventLogSink(\n options: WindowsEventLogSinkOptions,\n): Sink & Disposable {\n // Validate platform early\n validateWindowsPlatform();\n\n const {\n sourceName,\n eventIdMapping = {},\n } = options;\n\n // Merge with default event ID mapping\n const eventIds = { ...DEFAULT_EVENT_ID_MAPPING, ...eventIdMapping };\n\n let ffi: WindowsEventLogFFI | null = null;\n let initPromise: Promise<void> | null = null;\n const metaLogger = getLogger([\"logtape\", \"meta\", \"windows-eventlog\"]);\n\n const sink: Sink & Disposable = (record: LogRecord) => {\n // Format the complete message\n const message = formatMessage(record);\n const context = formatContext(record);\n const fullMessage = message + context;\n\n // Get event type and ID for this log level\n const eventType = mapLogLevelToEventType(record.level);\n const eventId = eventIds[record.level];\n\n // Initialize FFI on first use\n if (!ffi) {\n ffi = new WindowsEventLogFFI(sourceName);\n initPromise = ffi.initialize()\n .then(() => {\n // Write the first event after initialization\n if (ffi) {\n try {\n ffi.writeEvent(eventType, eventId, fullMessage);\n } catch (error) {\n metaLogger.error(\n \"Failed to write to Windows Event Log: {error}\",\n { error },\n );\n }\n }\n })\n .catch((error) => {\n metaLogger.error(\n \"Failed to initialize Windows Event Log FFI: {error}\",\n { error },\n );\n ffi = null; // Reset FFI on error\n initPromise = null;\n });\n } else if (initPromise) {\n // Still initializing - queue the write operation\n initPromise = initPromise.then(() => {\n if (ffi) {\n try {\n ffi.writeEvent(eventType, eventId, fullMessage);\n } catch (error) {\n metaLogger.error(\n \"Failed to write to Windows Event Log: {error}\",\n { error },\n );\n }\n }\n });\n } else {\n // Already initialized\n try {\n ffi.writeEvent(eventType, eventId, fullMessage);\n } catch (error) {\n metaLogger.error(\n \"Failed to write to Windows Event Log: {error}\",\n { error },\n );\n }\n }\n };\n\n // Implement Disposable for cleanup\n sink[Symbol.dispose] = () => {\n if (ffi) {\n ffi.dispose();\n ffi = null;\n }\n };\n\n return sink;\n}\n"],"mappings":";;;;;;;;;;AAeA,SAAS,cAAcA,QAA2B;CAChD,IAAI,UAAU;AAGd,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,IACzC,KAAI,IAAI,MAAM,EAEZ,YAAW,OAAO,QAAQ;MACrB;EAEL,MAAM,MAAM,OAAO,QAAQ;AAC3B,aAAW,QAAQ,SACjB,YAAW;MAEX,YAAW,KAAK,UAAU,IAAI;CAEjC;AAGH,QAAO;AACR;;;;;AAMD,SAAS,cAAcA,QAA2B;CAChD,MAAMC,UAAoB,CAAE;AAG5B,KAAI,OAAO,YAAY,OAAO,SAAS,SAAS,EAC9C,SAAQ,MAAM,YAAY,OAAO,SAAS,KAAK,IAAI,CAAC,EAAE;AAIxD,KAAI,OAAO,cAAc,OAAO,KAAK,OAAO,WAAW,CAAC,SAAS,EAC/D,SAAQ,MAAM,cAAc,KAAK,UAAU,OAAO,WAAW,CAAC,EAAE;AAIlE,SAAQ,MAAM,aAAa,IAAI,KAAK,OAAO,WAAW,aAAa,CAAC,EAAE;AAEtE,QAAO,QAAQ,SAAS,KAAK,MAAM,QAAQ,KAAK,KAAK,CAAC,IAAI;AAC3D;;;;;;;;;;;;;;;;;;;;;;;AAwBD,SAAgB,uBACdC,SACmB;AAEnB,0BAAyB;CAEzB,MAAM,EACJ,YACA,iBAAiB,CAAE,GACpB,GAAG;CAGJ,MAAM,WAAW;EAAE,GAAG;EAA0B,GAAG;CAAgB;CAEnE,IAAIC,MAAiC;CACrC,IAAIC,cAAoC;CACxC,MAAM,aAAa,UAAU;EAAC;EAAW;EAAQ;CAAmB,EAAC;CAErE,MAAMC,OAA0B,CAACL,WAAsB;EAErD,MAAM,UAAU,cAAc,OAAO;EACrC,MAAM,UAAU,cAAc,OAAO;EACrC,MAAM,cAAc,UAAU;EAG9B,MAAM,YAAY,uBAAuB,OAAO,MAAM;EACtD,MAAM,UAAU,SAAS,OAAO;AAGhC,OAAK,KAAK;AACR,SAAM,IAAI,mBAAmB;AAC7B,iBAAc,IAAI,YAAY,CAC3B,KAAK,MAAM;AAEV,QAAI,IACF,KAAI;AACF,SAAI,WAAW,WAAW,SAAS,YAAY;IAChD,SAAQ,OAAO;AACd,gBAAW,MACT,iDACA,EAAE,MAAO,EACV;IACF;GAEJ,EAAC,CACD,MAAM,CAAC,UAAU;AAChB,eAAW,MACT,uDACA,EAAE,MAAO,EACV;AACD,UAAM;AACN,kBAAc;GACf,EAAC;EACL,WAAU,YAET,eAAc,YAAY,KAAK,MAAM;AACnC,OAAI,IACF,KAAI;AACF,QAAI,WAAW,WAAW,SAAS,YAAY;GAChD,SAAQ,OAAO;AACd,eAAW,MACT,iDACA,EAAE,MAAO,EACV;GACF;EAEJ,EAAC;MAGF,KAAI;AACF,OAAI,WAAW,WAAW,SAAS,YAAY;EAChD,SAAQ,OAAO;AACd,cAAW,MACT,iDACA,EAAE,MAAO,EACV;EACF;CAEJ;AAGD,MAAK,OAAO,WAAW,MAAM;AAC3B,MAAI,KAAK;AACP,OAAI,SAAS;AACb,SAAM;EACP;CACF;AAED,QAAO;AACR"}
|
package/dist/types.d.cts
CHANGED
|
@@ -2,11 +2,6 @@ import { LogLevel } from "@logtape/logtape";
|
|
|
2
2
|
|
|
3
3
|
//#region types.d.ts
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Windows Event Log names supported by the sink.
|
|
7
|
-
* @since 1.0.0
|
|
8
|
-
*/
|
|
9
|
-
type WindowsLogName = "Application" | "System";
|
|
10
5
|
/**
|
|
11
6
|
* Configuration options for the Windows Event Log sink.
|
|
12
7
|
* @since 1.0.0
|
|
@@ -19,15 +14,6 @@ interface WindowsEventLogSinkOptions {
|
|
|
19
14
|
* @example "MyApplication"
|
|
20
15
|
*/
|
|
21
16
|
readonly sourceName: string;
|
|
22
|
-
/**
|
|
23
|
-
* The target Windows Event Log to write to.
|
|
24
|
-
*
|
|
25
|
-
* - "Application": Standard application log (most common)
|
|
26
|
-
* - "System": System-level log (requires admin privileges)
|
|
27
|
-
*
|
|
28
|
-
* @default "Application"
|
|
29
|
-
*/
|
|
30
|
-
readonly logName?: WindowsLogName;
|
|
31
17
|
/**
|
|
32
18
|
* The server name to write logs to. Use this for remote logging.
|
|
33
19
|
*
|
|
@@ -75,5 +61,5 @@ declare class WindowsEventLogError extends Error {
|
|
|
75
61
|
}
|
|
76
62
|
//# sourceMappingURL=types.d.ts.map
|
|
77
63
|
//#endregion
|
|
78
|
-
export { WindowsEventLogError, WindowsEventLogSinkOptions,
|
|
64
|
+
export { WindowsEventLogError, WindowsEventLogSinkOptions, WindowsPlatformError };
|
|
79
65
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAiC2C,UAjC1B,0BAAA,CAiC0B;EAAQ;;AAAhB;AAyDnC;AAeA;;EAAkC,SACK,UAAA,EAAA,MAAA;EAAK;AADG;;;;;;;;;;;;;;;;;;;;;;4BAxEnB,QAAQ,OAAO;;;;;;;;;;;;cAyD9B,oBAAA,SAA6B,KAAK;;;;;;;cAelC,oBAAA,SAA6B,KAAA;uCACH"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,11 +2,6 @@ import { LogLevel } from "@logtape/logtape";
|
|
|
2
2
|
|
|
3
3
|
//#region types.d.ts
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Windows Event Log names supported by the sink.
|
|
7
|
-
* @since 1.0.0
|
|
8
|
-
*/
|
|
9
|
-
type WindowsLogName = "Application" | "System";
|
|
10
5
|
/**
|
|
11
6
|
* Configuration options for the Windows Event Log sink.
|
|
12
7
|
* @since 1.0.0
|
|
@@ -19,15 +14,6 @@ interface WindowsEventLogSinkOptions {
|
|
|
19
14
|
* @example "MyApplication"
|
|
20
15
|
*/
|
|
21
16
|
readonly sourceName: string;
|
|
22
|
-
/**
|
|
23
|
-
* The target Windows Event Log to write to.
|
|
24
|
-
*
|
|
25
|
-
* - "Application": Standard application log (most common)
|
|
26
|
-
* - "System": System-level log (requires admin privileges)
|
|
27
|
-
*
|
|
28
|
-
* @default "Application"
|
|
29
|
-
*/
|
|
30
|
-
readonly logName?: WindowsLogName;
|
|
31
17
|
/**
|
|
32
18
|
* The server name to write logs to. Use this for remote logging.
|
|
33
19
|
*
|
|
@@ -75,5 +61,5 @@ declare class WindowsEventLogError extends Error {
|
|
|
75
61
|
}
|
|
76
62
|
//# sourceMappingURL=types.d.ts.map
|
|
77
63
|
//#endregion
|
|
78
|
-
export { WindowsEventLogError, WindowsEventLogSinkOptions,
|
|
64
|
+
export { WindowsEventLogError, WindowsEventLogSinkOptions, WindowsPlatformError };
|
|
79
65
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../types.ts"],"sourcesContent":[],"mappings":";;;;;;AAMA;;AAiC2C,UAjC1B,0BAAA,CAiC0B;EAAQ;;AAAhB;AAyDnC;AAeA;;EAAkC,SACK,UAAA,EAAA,MAAA;EAAK;AADG;;;;;;;;;;;;;;;;;;;;;;4BAxEnB,QAAQ,OAAO;;;;;;;;;;;;cAyD9B,oBAAA,SAA6B,KAAK;;;;;;;cAelC,oBAAA,SAA6B,KAAA;uCACH"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["DEFAULT_EVENT_ID_MAPPING: Record<LogLevel, number>","level: LogLevel","platform: string","message: string","cause?: Error"],"sources":["../types.ts"],"sourcesContent":["import type { LogLevel } from \"@logtape/logtape\";\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"types.js","names":["DEFAULT_EVENT_ID_MAPPING: Record<LogLevel, number>","level: LogLevel","platform: string","message: string","cause?: Error"],"sources":["../types.ts"],"sourcesContent":["import type { LogLevel } from \"@logtape/logtape\";\n\n/**\n * Configuration options for the Windows Event Log sink.\n * @since 1.0.0\n */\nexport interface WindowsEventLogSinkOptions {\n /**\n * The name of the event source. This is typically your application name\n * and will appear as the \"Source\" in Windows Event Viewer.\n *\n * @example \"MyApplication\"\n */\n readonly sourceName: string;\n\n /**\n * The server name to write logs to. Use this for remote logging.\n *\n * @default undefined (local machine)\n */\n readonly serverName?: string;\n\n /**\n * Custom mapping of LogTape log levels to Windows Event IDs.\n * Event IDs are numeric identifiers that can be used for filtering\n * and automation in Windows Event Log.\n *\n * @default\n * ```typescript\n * {\n * fatal: 1,\n * error: 2,\n * warning: 3,\n * info: 4,\n * debug: 5,\n * trace: 6\n * }\n * ```\n */\n readonly eventIdMapping?: Partial<Record<LogLevel, number>>;\n}\n\n/**\n * Windows Event Log entry types mapped to LogTape levels.\n * These correspond to the event types visible in Windows Event Viewer.\n * @since 1.0.0\n */\nexport const WINDOWS_EVENT_TYPES: Record<LogLevel, number> = {\n fatal: 1, // Error\n error: 1, // Error\n warning: 2, // Warning\n info: 4, // Information\n debug: 4, // Information\n trace: 4, // Information\n} as const;\n\n/**\n * Default Event ID mapping for LogTape levels.\n * @since 1.0.0\n */\nexport const DEFAULT_EVENT_ID_MAPPING: Record<LogLevel, number> = {\n fatal: 1,\n error: 2,\n warning: 3,\n info: 4,\n debug: 5,\n trace: 6,\n} as const;\n\n/**\n * Windows Event Log event type constants\n */\nexport type EventType = 1 | 2 | 4; // Error, Warning, Information\n\n/**\n * Maps LogTape log levels to Windows Event Log event types\n */\nexport function mapLogLevelToEventType(level: LogLevel): EventType {\n switch (level) {\n case \"fatal\":\n case \"error\":\n return 1; // EVENTLOG_ERROR_TYPE\n case \"warning\":\n return 2; // EVENTLOG_WARNING_TYPE\n case \"info\":\n case \"debug\":\n case \"trace\":\n default:\n return 4; // EVENTLOG_INFORMATION_TYPE\n }\n}\n\n/**\n * Platform validation error thrown when trying to use the sink on non-Windows platforms.\n * @since 1.0.0\n */\nexport class WindowsPlatformError extends Error {\n constructor(platform: string) {\n super(\n `Windows Event Log sink can only be used on Windows platforms. ` +\n `Current platform: ${platform}. ` +\n `This package is designed specifically for Windows Event Log integration.`,\n );\n this.name = \"WindowsPlatformError\";\n }\n}\n\n/**\n * Error thrown when Windows Event Log operations fail.\n * @since 1.0.0\n */\nexport class WindowsEventLogError extends Error {\n constructor(message: string, cause?: Error) {\n super(`Windows Event Log error: ${message}`);\n this.name = \"WindowsEventLogError\";\n if (cause) {\n this.cause = cause;\n }\n }\n}\n"],"mappings":";;;;;AA4DA,MAAaA,2BAAqD;CAChE,OAAO;CACP,OAAO;CACP,SAAS;CACT,MAAM;CACN,OAAO;CACP,OAAO;AACR;;;;AAUD,SAAgB,uBAAuBC,OAA4B;AACjE,SAAQ,OAAR;EACE,KAAK;EACL,KAAK,QACH,QAAO;EACT,KAAK,UACH,QAAO;EACT,KAAK;EACL,KAAK;EACL,KAAK;EACL,QACE,QAAO;CACV;AACF;;;;;AAMD,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAYC,UAAkB;AAC5B,SACG,kFACsB,SAAS,4EAEjC;AACD,OAAK,OAAO;CACb;AACF;;;;;AAMD,IAAa,uBAAb,cAA0C,MAAM;CAC9C,YAAYC,SAAiBC,OAAe;AAC1C,SAAO,2BAA2B,QAAQ,EAAE;AAC5C,OAAK,OAAO;AACZ,MAAI,MACF,MAAK,QAAQ;CAEhB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logtape/windows-eventlog",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.229+a2595df7",
|
|
4
4
|
"description": "Windows Event Log sink for LogTape",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"dist/"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@logtape/logtape": "1.0.0-dev.
|
|
53
|
+
"@logtape/logtape": "1.0.0-dev.229+a2595df7"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"koffi": "^2.10.0"
|