anchor.diff:  
   ;; Server logging
   
  +(defparameter *reconnect-timeout* 10)
  +
  +
   (defun log-server (server port nick channels)
     "Run logging loop for specified server."
     (handler-bind ((nickname-already-in-use
                     #'(lambda (c)
                         (declare (ignore c))
  +                      (format t "Sucks, nick used~%")
                         (invoke-restart 'change-nick))))
  -    (let ((sock (connect server port nick channels)))
  -      (do ((line
  -            (read-line (usocket:socket-stream sock) nil)
  -            (read-line (usocket:socket-stream sock) nil)))
  -          ((not line))
  -        (format t "Received: ~A~%" line)
  -        (if (string-prefix-p "PING" line)
  -            (send-pong sock line)
  -            (restart-case
  -                (let ((message (parse-message line)))
  -                  (process message))
  -              (continue () nil)
  -              (change-nick ()
  +    (loop do
  +         (let* ((socket (usocket:socket-connect server port))
  +                (stream (usocket:socket-stream socket)))
  +           (unwind-protect
                   (progn
  -                  (setf nick (concatenate 'string nick "-"))
  -                  (set-nick sock nick)))))))))
  +                  (set-nick stream nick)
  +                  (send-cmd stream "JOIN ~{#~a~^,~}" channels)
  +                  (do ((line
  +                        (read-line stream nil)
  +                        (read-line stream nil)))
  +                      ((not line))
  +                    (if (string-prefix-p "PING" line)
  +                        (send-pong stream line)
  +                        (restart-case
  +                            (let ((message (parse-message line)))
  +                              (process message))
  +                          (continue () nil)
  +                          (change-nick ()
  +                            (progn
  +                              (setf nick (concatenate 'string nick "-"))
  +                              (set-nick stream nick)))))))
  +             (close stream)
  +             (usocket:socket-close socket))
  +           ;; Do-loop ends when socket disconnected, reconnect after
  +           ;; timeout
  +           (format t "Reconnecting~%")
  +           (sleep *reconnect-timeout*)))))
  
positive.code: 
  ;; Errors
  (define-condition nickname-already-in-use (error)
    ((text :initarg :text :reader text)))
  
  ;; IRC message classes
  
negative.code: (in-package #:zoglog)
  
  ;; Helper functions
  (defmacro send-cmd (stream tpl &rest args)
    "Send IRC command through STREAM."
    `(progn
       (format ,stream
               (concatenate 'string ,tpl "~C~C")
               ,@args #\return #\linefeed)
       (finish-output ,stream)))
  
  (defun set-nick (stream nick)
    "Set user name for server."
    (send-cmd stream "NICK ~a" nick)
    (send-cmd stream "USER ~a ~:*~a ~:*~a :~:*~a" nick))
  
  (defun string-prefix-p (string line)
    "Check if LINE starts with STRING."
    (let ((pos (search string line)))
      (and pos (= pos 0))))
  
  (defun send-pong (stream line)
    "Send 'PONG' in answer to 'PING' line throuck STREAM."
    (let ((data (string-trim '(#\space #\return #\newline)
                             (cadr (split-sequence #\colon line :count 2)))))
      (send-cmd stream "PONG :~a" data)))
  
  (defun split-once (line seq)
    "Split string LINE by sequence SEQ once."
  