a90915886996646bb1b9c5faaba1ecd5b2d9b89b
[virt-top.git] / virt-top / virt_top_csv.ml
1 (* 'top'-like tool for libvirt domains.
2  * $Id: virt_top_csv.ml,v 1.1 2007/08/23 11:09:19 rjones Exp $
3  *
4  * This file contains all code which requires CSV support.
5  *)
6
7 (* Output channel, or None if CSV output not enabled. *)
8 let chan = ref None ;;
9
10 Virt_top.csv_start :=
11   fun filename ->
12     chan := Some (open_out filename) ;;
13
14 Virt_top.csv_write :=
15   fun row ->
16     match !chan with
17     | None -> ()                        (* CSV output not enabled. *)
18     | Some chan ->
19         Csv.save_out chan [row];
20         (* Flush the output to the file immediately because we don't
21          * explicitly close this file.
22          *)
23         flush chan