/*1Initialize debug logging.23We use the standard debug logger with name "posix-node": https://www.npmjs.com/package/debug45DEBUG_FILE option:67To log to a file instead *also* set the env variable DEBUG_FILE to that8filename. You need to log to a file in case you're debugging something that9forks and doesn't have stdout/stderr anymore. Also, we do NOT reset the10contents of the file and instead always append, because forking would be a11problem, where the forked process might delete the file in the middle of the12run.13*/1415import debug from "debug";16import { format } from "util";17import { appendFileSync } from "fs";1819if (process.env.DEBUG_FILE) {20const debugFilename = process.env.DEBUG_FILE;21debug.log = (...args) => {22const s = format(...args);23appendFileSync(debugFilename, s + "\n");24};25}2627export const log = debug("posix-node");282930