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