Update of /project/log4cl/cvsroot/log4cl In directory common-lisp.net:/tmp/cvs-serv26132
Modified Files: appender.lisp Log Message: Add network appender
Date: Fri Mar 5 10:08:27 2004 Author: nlamirault
Index: log4cl/appender.lisp diff -u log4cl/appender.lisp:1.4 log4cl/appender.lisp:1.5 --- log4cl/appender.lisp:1.4 Tue Mar 2 13:37:45 2004 +++ log4cl/appender.lisp Fri Mar 5 10:08:27 2004 @@ -21,6 +21,7 @@
(defclass appender () ((name :initarg :name + :initform nil :accessor appender-name) (layout :initarg :layout :accessor appender-layout)) @@ -28,8 +29,10 @@
(defmethod initialize-instance :after ((appender appender) &rest initargs) (declare (ignore initargs)) - (with-slots (layout) appender - (setf layout (make-instance 'simple-layout)))) + (with-slots (layout name) appender + (setf layout (make-instance 'simple-layout)) + (when (null name) + (setf name (type-of appender)))))
;; ---------- ;; Protocole @@ -167,3 +170,36 @@ (cons "M" (write-to-string month)) (cons "D" (write-to-string date))))) (replace-string date-pattern pattern)))) + + + +;; ----------------- +;; Network Appender +;; ----------------- + + +(defclass network-appender (appender) + ((server :initarg :server + :accessor network-appender-server) + (data :initarg :data + :initform '() + :accessor network-appender-data) + (items :initarg :size + :initform 10 + :accessor network-appender-items)) + (:documentation "Network appender bufferize logs message, and send them when size is over")) + + +(defmethod log-msg ((appender network-appender) name level message) + (setf (slot-value appender 'data) + (cons (format-log-message (appender-layout appender) name level message) + (network-appender-data appender)))) + + +(defun create-buffer (tokens) + "Create a paragrah from a list of string" + (apply #'concatenate 'string + (mapcar #'(lambda (token) + (let ((new-token (format nil "~A~%" token))) + (concatenate 'string new-token))) + tokens)))