let log ?depth t =
to_flat_list t
|> fun l ->
begin match depth with
| Some d -> List.take l d
| None -> l
end
|> List.map ~f:(fun (time, name, msgopt, bookopt) ->
Log.(s "* " % Time.log time % s ": " % s name
% (match msgopt with None -> empty | Some m -> n % indent (s m))
% (match bookopt with None -> empty | Some m -> n % indent (s m))))
|> Log.(separate n)