/*
 * Copyright (c) 2018, 2025, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
function Writer(nd,msgCtx){this._logFile=false;this._toFile=false;this._toCon=msgCtx.console;this._toError=msgCtx.error;this._nd=nd};Writer.prototype.put=function(msg){if(this._toFile){try{this._nd.fs.appendFileSync(this._logFile,msg+"\r\n",{encoding:"utf8"})}catch(e){this._toError("[Error]: writing to output - reason ["+e.message+"]");this._toCon(msg)}}else{this._toCon(msg)}};Writer.prototype.open=function(filePath){var ret=null;if(filePath){this._logFile=filePath;if(this._nd.fs.existsSync(filePath)){this._nd.fs.unlinkSync(filePath)}try{this._nd.fs.openSync(filePath,"a");this._toFile=true}catch(err){ret=err}}return ret};module.exports=Writer;