import { __esmMin } from "../../../_virtual/_rolldown/runtime.js";
import { closeStreams, init_streams } from "./streams.js";
//#region src/utils/logger/shutdown.ts
/**
* Check if logger is shutting down
*/
function isLoggerShuttingDown() {
	return isShuttingDown;
}
/**
* Set shutdown state
*/
function setShuttingDown(value) {
	isShuttingDown = value;
}
/**
* Flush and close all streams
* Must be called before process exit
*/
async function flushAndClose() {
	isShuttingDown = true;
	try {
		await closeStreams();
	} catch {}
}
/**
* Register shutdown handlers
*/
function registerShutdownHandler() {
	if (shutdownHandler) return;
	shutdownHandler = async () => {
		await flushAndClose();
	};
	process.on("SIGINT", shutdownHandler);
	process.on("SIGTERM", shutdownHandler);
	process.on("exit", () => {
		if (shutdownHandler) shutdownHandler();
	});
}
var isShuttingDown, shutdownHandler;
var init_shutdown = __esmMin((() => {
	init_streams();
	isShuttingDown = false;
	shutdownHandler = null;
	registerShutdownHandler();
}));
//#endregion
init_shutdown();
export { flushAndClose, init_shutdown, isLoggerShuttingDown, registerShutdownHandler, setShuttingDown };

//# sourceMappingURL=shutdown.js.map