Prev | Current Page 603 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


The next task you ??™ re faced with is accepting a stream for output. Now, this class should be able to output
to any stream, but at the same time, it needs to be able to create its own file stream by default. Therefore,
the method for outputting data and the method for creating a stream should be separated, so that one
might be overridden by the consuming application.
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();
(continued)
313
Chapter 11: Performing Server-Side Trickery
// create stream
var stream = getStream();
// ...
}
public static function getStream() : neko.io.Output
{
var file = location;
file += if ( !StringTools.endsWith( file, ???/??? ) & &
!StringTools.endsWith( file, ???\\??? ) ) ???/??? else ??????;
file += getLogFileName();
return if ( neko.


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