It turned out to be quite inconvenient to have to close the substreams in
topological order. I have introduced use counts on all streams: A newly
created stream has use count of 1, whenever it is used as a substream,
the use count increases; when the count drops to 0, the stream is
automatically destroyed.
A slightly unpleasant side-effect is that the default log stream
can no longer be constant, since we modify its counter.
I have also extended log_rm_substream() to remove all substreams
when what==NULL. This is useful in log_close_stream() and also
in log_file().