Skip to contents

Unregisters one or more sinks by id. Ids that are not registered are ignored, so cleanup code can run unconditionally. The reserved "console" id can be removed like any other, which is how a library silences logtree's console output outright.

Usage

logtree_sink_remove(id)

Arguments

id

Character vector of sink ids, as returned by logtree_sink(), logtree_sink_file() or logtree_sinks().

Value

The removed sink functions, invisibly: a named list keyed by the ids actually removed (empty when none matched). Re-registering one with logtree_sink() restores it, under a fresh id and therefore at the end of the firing order.

Details

Sinks deliberately survive logtree_reset(), so this is the only way to take one off again.

Examples

logtree_reset()
h <- logtree_sink(function(event) invisible(NULL))
logtree_sinks()
#> [1] "console" "sink3"   "sink4"   "sink5"   "sink6"   "sink9"  
logtree_sink_remove(h)
logtree_sinks()
#> [1] "console" "sink3"   "sink4"   "sink5"   "sink6"