(* log.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. *) structure Log : sig val init : string -> unit val logFile : unit -> TextIO.outstream val msg : string -> unit end = struct val logStrm : TextIO.outstream option ref = ref NONE fun init file = (case !logStrm of NONE => let val outS = TextIO.openOut file in (* turn off buffering *) TextIO.StreamIO.setBufferMode (TextIO.getOutstream outS, IO.NO_BUF); logStrm := SOME outS end | SOME strm => raise Fail "multiple initialization of log file" (* end case *)) fun logFile () = (case !logStrm of NONE => (init "/dev/null"; logFile()) | SOME outS => outS (* end case *)) fun msg s = TextIO.output(logFile(), s); end
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: ()) | SOME outS => outS (* end case *)) fun msg s = TextIO.output(logFile(), s); end