-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathlog.ml
More file actions
27 lines (22 loc) · 712 Bytes
/
log.ml
File metadata and controls
27 lines (22 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(*
* iocaml - an OCaml kernel for IPython
*
* (c) 2014 MicroJamJar Ltd
*
* Author(s): andy.ray@ujamjar.com
* Description: log file for debugging
*
*)
let log' = ref (fun s -> ())
let time() =
let open Unix in
let tm = localtime (time ()) in
Printf.sprintf "%i/%i/%i %.2i:%.2i:%.2i"
tm.tm_mday (tm.tm_mon+1) (tm.tm_year+1900) tm.tm_hour tm.tm_min tm.tm_sec
let open_log_file s =
(*let flog = open_out_gen [Open_text;Open_creat;Open_append] 0o666 s in*)
let flog = open_out s in
let () = at_exit (fun () -> close_out flog) in
log' := (fun s -> output_string flog s; flush flog);
!log' (Printf.sprintf "iocaml log file: %s\n" (time()))
let log s = !log' s