import path from 'path-browserify';
export class FileLogger {
    _filePath;
    _workspace;
    constructor(_filePath, _workspace) {
        this._filePath = _filePath;
        this._workspace = _workspace;
    }
    static async create(filePath, workspace) {
        const logDir = path.dirname(filePath);
        if (!(await workspace.exists(logDir))) {
            await workspace.mkdir(logDir, { recursive: true });
        }
        if (await workspace.exists(filePath)) {
            await workspace.rm(filePath);
        }
        return new FileLogger(filePath, workspace);
    }
    async info(info) {
        await this._workspace.appendFile(this._filePath, `${info}  \n`);
    }
    notice(msg) {
        return this.info(`${msg}  \n`);
    }
    success(msg) {
        return this.info(`${msg}  \n`);
    }
    warning(msg) {
        return this.info(`${msg}  \n`);
    }
    error(msg) {
        return this.info(`${msg}  \n`);
    }
}
