From: Kevin M. Rosenberg Date: Tue, 16 Dec 2003 22:49:11 +0000 (+0000) Subject: r8343: use new background function X-Git-Tag: v0.9.3~43 X-Git-Url: http://git.kpe.io/?p=irc-logger.git;a=commitdiff_plain;h=5bce8846ed56d86d07b41f5fcb27e2630d82c4e1 r8343: use new background function --- diff --git a/logger.lisp b/logger.lisp index 9123cb8..e0da56a 100644 --- a/logger.lisp +++ b/logger.lisp @@ -59,13 +59,13 @@ (defgeneric write-file-header (format channel-name stream)) (defmethod write-file-header ((format t) channel-name stream) - (declare (ignore format channel-name stream)) + (declare (ignore channel-name stream)) ) (defgeneric write-file-footer (format channel-name stream)) (defmethod write-file-footer ((format t) channel-name stream) - (declare (ignore format channel-name stream)) + (declare (ignore channel-name stream)) ) (defun %log-file-path (output-root channel-name year month day type) @@ -80,7 +80,8 @@ (defgeneric log-file-path (output-root channel-name year month day format)) -(defmethod log-file-path (output-root channel-name year month day (format (eql :raw))) +(defmethod log-file-path (output-root channel-name year month day + (format (eql :raw))) (%log-file-path output-root channel-name year month day "raw")) (defmethod log-file-path (output-root channel-name year month day (format (eql :sexp))) @@ -174,16 +175,18 @@ (defun need-user-address? (type) (not (or (eq :action type) (eq :privmsg type)))) -(defgeneric %output-event (format stream utime type channel source text msg unichannel)) +(defgeneric %output-event (format stream utime type channel source text msg + unichannel)) (defmethod %output-event ((format t) stream utime type channel source text msg unichannel) (%output-event :raw stream utime type channel source text msg unichannel)) -(defmethod %output-event ((format (eql :raw)) stream utime type channel source text - msg unichannel) - (declare (ignore unichannel)) - (format stream "~S~%" (string-right-trim '(#\return) (raw-message-string msg)))) +(defmethod %output-event ((format (eql :raw)) stream utime type channel source + text msg unichannel) + (declare (ignore utime type channel source text text unichannel )) + (format stream "~S~%" (string-right-trim '(#\return) + (raw-message-string msg)))) (defmethod %output-event ((format (eql :sexp)) stream utime type channel source text msg unichannel) @@ -296,7 +299,6 @@ (defun create-logger (nick server &key channels output (logging-stream t) - (async t) (formats '(:text))) "OUTPUT may be a pathname or a stream" ;; check arguments @@ -331,14 +333,13 @@ (add-hook conn 'irc::irc-mode-message 'mode-hook) (add-hook conn 'irc::irc-topic-message 'topic-hook) (add-hook conn 'irc::irc-notice-message 'notice-hook) - (cond - (async - #+sbcl (add-asynchronous-message-handler conn) - #-sbcl (read-message-loop conn)) - (t - (read-message-loop conn))) logger)) +(defun start-logger (logger async) + (if async + (read-message-loop-background (connection logger)) + (read-message-loop (connection logger)))) + (defun quit-logger (nick) "Quit the active connection with nick and remove from active list." (let ((logger (find-logger-with-nick nick))) @@ -365,15 +366,15 @@ (when (find-logger-with-nick nick) (warn "Closing previously active connection.") (quit-logger nick)) - (let ((logger - (create-logger nick server :channels channels :output output - :logging-stream logging-stream - :async async :formats formats))) + (let ((logger (create-logger nick server :channels channels :output output + :logging-stream logging-stream + :formats formats))) (push logger *loggers*) + (start-logger logger async) logger)) -(defun add-hook-logger (logger msg hook) - (add-hook (connection logger) msg hook)) +(defun add-hook-logger (logger class hook) + (add-hook (connection logger) class hook)) -(defun remove-hook-logger (logger msg) - (remove-hook (connection logger) msg)) +(defun remove-hook-logger (logger class hook) + (remove-hook (connection logger) class hook))