Prev | Current Page 604 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

FileSystem.exists( file ) )
neko.io.File.append( file, false )
else
neko.io.File.write( file, false );
}
All you ??™ ve really done here is to provide a getStream method that returns a stream of type neko
.io.Output . This should cater for any type of output stream, so you ??™ re fully covered. If a particular
application wants to provide its own stream type, it needn ??™ t worry about parameter type confliction.
This is why the method accepts no parameters, but instead relies entirely on static variables.
Now, you need to output the string data to the stream and then close it, remembering to first flush the
stream of data:
public static function log( val : String, ?bold : Bool )
{
// create time stamp
var h = Date.now().getHours();
var m = Date.now().getMinutes();
var s = Date.now().getSeconds();
var str = ???\n??? + h + ???:??? + m + ???:??? + s + ??? - ??? + val + ???\n???;
// append highlight if bold = true
if ( bold ) str = header() + str + footer();
// create stream
var stream = getStream();
// output bytes
stream.


Pages:
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616