Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /trunk/src/compiler/common/log.sml
ViewVC logotype

Diff of /trunk/src/compiler/common/log.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 339, Mon Sep 13 14:55:51 2010 UTC revision 340, Mon Sep 13 15:34:36 2010 UTC
# Line 6  Line 6 
6    
7  structure Log : sig  structure Log : sig
8    
9        val enabled : unit -> bool
10    
11      val init : string -> unit      val init : string -> unit
12    
13      val logFile : unit -> TextIO.outstream      val logFile : unit -> TextIO.outstream
# Line 14  Line 16 
16    
17    end = struct    end = struct
18    
19        val enabledFlg = ref false
20      val logStrm : TextIO.outstream option ref = ref NONE      val logStrm : TextIO.outstream option ref = ref NONE
21    
22        fun enabled () = !enabledFlg
23    
24      fun init file = (case !logStrm      fun init file = (case !logStrm
25             of NONE => let             of NONE => let
26                  val outS = TextIO.openOut file                  val outS = TextIO.openOut file
27                  in                  in
28                      enabledFlg := true;
29                  (* turn off buffering *)                  (* turn off buffering *)
30                    TextIO.StreamIO.setBufferMode (TextIO.getOutstream outS, IO.NO_BUF);                    TextIO.StreamIO.setBufferMode (TextIO.getOutstream outS, IO.NO_BUF);
31                    logStrm := SOME outS                    logStrm := SOME outS
# Line 28  Line 34 
34            (* end case *))            (* end case *))
35    
36      fun logFile () = (case !logStrm      fun logFile () = (case !logStrm
37             of NONE => (init "/dev/null"; logFile())             of NONE => (init "/dev/null"; enabledFlg := false; logFile())
38              | SOME outS => outS              | SOME outS => outS
39            (* end case *))            (* end case *))
40    
41      fun msg s = TextIO.output(logFile(), s);      fun msg s = if !enabledFlg then TextIO.output(logFile(), s) else ();
42    
43    end    end
44    

Legend:
Removed from v.339  
changed lines
  Added in v.340

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0