diff --git a/src/ufront/tasks/UFTaskSet.hx b/src/ufront/tasks/UFTaskSet.hx index 5c54348..212526b 100644 --- a/src/ufront/tasks/UFTaskSet.hx +++ b/src/ufront/tasks/UFTaskSet.hx @@ -1,6 +1,5 @@ package ufront.tasks; -#if sys import mcli.CommandLine; import mcli.Dispatch; import minject.Injector; @@ -12,6 +11,7 @@ import ufront.log.MessageList; import ufront.api.UFApi; import haxe.PosInfos; using haxe.io.Path; +using StringTools; class UFTaskSet extends CommandLine { @@ -47,23 +47,36 @@ class UFTaskSet extends CommandLine { **/ @:skip public function useCLILogging( ?logFile:String ):UFTaskSet { + var logFilePath = null; var file:FileOutput = null; if ( logFile!=null ) { var contentDir:String = injector.getInstance( String, "contentDirectory" ); - var logFilePath = contentDir.addTrailingSlash()+logFile; + logFilePath = contentDir.addTrailingSlash()+logFile; var logFileDirectory = logFilePath.directory(); if ( FileSystem.exists(logFileDirectory)==false ) FileSystem.createDirectory( logFileDirectory ); - file = File.append( logFilePath ); + var line = '${Date.now()} [UFTask Runner] ${Sys.args()}'; - file.writeString( '$line\n' ); + + #if nodejs + // hxnodejs has no FileInput implemention (yet) + js.node.Fs.appendFileSync( logFilePath, '$line\n' ); + #else + file = File.append( logFilePath ); + file.writeString( '$line\n' ); + #end + } function onMessage( msg:Message ) { var line = FileLogger.format( msg ); + Sys.println( line ); - if ( file!=null ) { - file.writeString( '\t$line\n' ); - } +#if nodejs + // hxnodejs has no FileInput implemention (yet) + if ( logFilePath!=null ) js.node.Fs.appendFileSync( logFilePath, '\t$line\n' ); +#else + if ( file!=null ) file.writeString( '\t$line\n' ); +#end } haxe.Log.trace = function(msg:Dynamic,?pos:PosInfos) onMessage({ msg: msg, pos: pos, type:MTrace }); injector.map( MessageList ).toValue( new MessageList(onMessage) ); @@ -141,4 +154,3 @@ class UFTaskSet extends CommandLine { **/ @:noCompletion inline function ufError( msg:Dynamic, ?pos:PosInfos ) messages.push({ msg: msg, pos: pos, type:MError }); } -#end