SCM Repository
Annotation of /trunk/src/compiler/common/log.sml
Parent Directory
|
Revision Log
Revision 237 - (view) (download)
1 : | jhr | 237 | (* log.sml |
2 : | * | ||
3 : | * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) | ||
4 : | * All rights reserved. | ||
5 : | *) | ||
6 : | |||
7 : | structure Log : sig | ||
8 : | |||
9 : | val init : string -> unit | ||
10 : | |||
11 : | val logFile : unit -> TextIO.outstream | ||
12 : | |||
13 : | val msg : string -> unit | ||
14 : | |||
15 : | end = struct | ||
16 : | |||
17 : | val logStrm : TextIO.outstream option ref = ref NONE | ||
18 : | |||
19 : | fun init file = (case !logStrm | ||
20 : | of NONE => let | ||
21 : | val outS = TextIO.openOut file | ||
22 : | in | ||
23 : | (* turn off buffering *) | ||
24 : | TextIO.StreamIO.setBufferMode (TextIO.getOutstream outS, IO.NO_BUF); | ||
25 : | logStrm := SOME outS | ||
26 : | end | ||
27 : | | SOME strm => raise Fail "multiple initialization of log file" | ||
28 : | (* end case *)) | ||
29 : | |||
30 : | fun logFile () = (case !logStrm | ||
31 : | of NONE => (init "/dev/null"; logFile()) | ||
32 : | | SOME outS => outS | ||
33 : | (* end case *)) | ||
34 : | |||
35 : | fun msg s = TextIO.output(logFile(), s); | ||
36 : | |||
37 : | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |