/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { open } from "node:fs/promises";
async function createFileLogger(path) {
  const fileHandle = await open(path, "a");
  const writer = fileHandle.createWriteStream();
  process.on(
    "beforeExit",
    () => void fileHandle.close().catch((err) => err && console.error(`Failed to close log file: ${err}`))
  );
  return (formattedLog) => {
    try {
      writer.write(`${formattedLog}
`);
    } catch (error) {
      console.error(`Failed to write to log file: ${error}`);
    }
  };
}
export {
  createFileLogger
};
//# sourceMappingURL=FileLogger.js.map
