// Library for logging things in JavaScript function Logger( inFile ) { // member properties // the file we are currently logging to if ( undefined == inFile ) { this.file = new File( Folder.desktop + "/Logger.log" ); } else { this.file = new File( inFile ); } // member methods // output to the ESTK console this.print = function( inMessage ) { if ( app.name == "ExtendScript Toolkit" ) { print (inMessage); } else { var btMessage = new BridgeTalk(); btMessage.target = "estoolkit"; btMessage.body = "print(" + inMessage.toSource() + ")"; btMessage.send (); } } // write out a message to the log file this.log = function( inMessage ) { if ( this.file.exists ) { this.file.open( 'e' ); this.file.seek( 0, 2 ); // end of file } else { this.file.open( 'w' ); } this.file.write( inMessage ); this.file.close(); } // show the contents with the execute method this.display = function() { this.file.execute(); } // remove the file this.remove = function() { this.file.remove(); } } /* Test harness for Logger var a = new Logger(); a.print( 'hello' ); a.print( 'hello2\n\n\nHi\n' ) ; a.remove(); a.log( Date() ); a.print( Date() ); a.display(); */