log: add support for logging rules

By default, everything is logged. The first matching rule wins.
Negation (!) and wildcards (*) are supported.

For example, disable logging for all channels, except #znc:

    /msg *log setrules #znc !#*

Queries do not match either of the above rules, so they get logged.