@logtape/windows-eventlog
Version:
Windows Event Log sink for LogTape
55 lines (53 loc) • 1.39 kB
JavaScript
//#region types.ts
/**
* Default Event ID mapping for LogTape levels.
* @since 1.0.0
*/
const DEFAULT_EVENT_ID_MAPPING = {
fatal: 1,
error: 2,
warning: 3,
info: 4,
debug: 5,
trace: 6
};
/**
* Maps LogTape log levels to Windows Event Log event types
*/
function mapLogLevelToEventType(level) {
switch (level) {
case "fatal":
case "error": return 1;
case "warning": return 2;
case "info":
case "debug":
case "trace":
default: return 4;
}
}
/**
* Platform validation error thrown when trying to use the sink on non-Windows platforms.
* @since 1.0.0
*/
var WindowsPlatformError = class extends Error {
constructor(platform) {
super(`Windows Event Log sink can only be used on Windows platforms. Current platform: ${platform}. This package is designed specifically for Windows Event Log integration.`);
this.name = "WindowsPlatformError";
}
};
/**
* Error thrown when Windows Event Log operations fail.
* @since 1.0.0
*/
var WindowsEventLogError = class extends Error {
constructor(message, cause) {
super(`Windows Event Log error: ${message}`);
this.name = "WindowsEventLogError";
if (cause) this.cause = cause;
}
};
//#endregion
exports.DEFAULT_EVENT_ID_MAPPING = DEFAULT_EVENT_ID_MAPPING;
exports.WindowsEventLogError = WindowsEventLogError;
exports.WindowsPlatformError = WindowsPlatformError;
exports.mapLogLevelToEventType = mapLogLevelToEventType;