+(defun add-channel-logger (logger channel-name)
+ (cond
+ ((find-channel-with-name logger channel-name)
+ (warn "Channel ~A already in logger ~A." channel-name logger)
+ nil)
+ (t
+ (let ((channel (make-a-channel channel-name (formats logger) (user-output logger))))
+ (join (connection logger) channel-name)
+ (push channel (channels logger))))))
+
+(defun remove-channel-logger (logger channel-name)
+ (let ((channel (find-channel-with-name logger channel-name)))
+ (cond
+ (channel
+ (part (connection logger) channel-name)
+ (dotimes (i (length (streams channel)))
+ (when (streamp (get-stream channel i))
+ (close (get-stream channel i))
+ (setf (get-stream channel i) nil)))
+ (setf (channels logger) (delete channel-name (channels logger)
+ :test #'string-equal
+ :key #'name))
+ t)
+ (t
+ (warn "Channel name ~A not found in logger ~A."
+ channel-name logger)
+ nil))))
+
+(defun add-hook-logger (logger class hook)
+ (add-hook (connection logger) class hook))
+
+(defun remove-hook-logger (logger class hook)
+ (remove-hook (connection logger) class hook))
+
+;; before disconnect, server usually sends something like
+;;
+;; Closing Link: nick[ipaddr or hostname] by servername (reason)
+;; some other reasons are: "G-lined", "K-lined", and "Your host is
+;; trying to (re)connect too fast -- throttled"
+;;
+;; reconnect should wait 30 sec depending upon the throttle
+;;
+;; avoid too many reconnect messages in the logs
+;;
+;; grep'ing around the net-nittin-ir source, it looks like 361
+;; rpl_killdone and 362 rpl_closing may refer to the closing link
+;; error i mention, as in, modern ircds may use numerics for such
+;; logging of unhandled numerics is good to do also