Explorar el Código

Log4cl logging

Innocenty Enikeew hace 11 años
padre
commit
86289a658a
Se han modificado 6 ficheros con 13 adiciones y 11 borrados
  1. 2 2
      src/financisto.lisp
  2. 2 2
      src/foursquare.lisp
  3. 4 4
      src/locations.lisp
  4. 2 2
      src/twitter.lisp
  5. 1 0
      src/web.lisp
  6. 2 1
      timeliner.asd

+ 2 - 2
src/financisto.lisp

@@ -151,7 +151,7 @@
          (balances (make-hash-table :size (hash-table-count (gethash "account" db))))
          (existing-docs (docs (db.find "events" ($ "type" "finance")
                                        :limit (floor (* 1.1 (length transactions)))))))
-    (format t "Got ~A with ~A transactions~%" filename (length transactions))
+    (log:info "Got ~A with ~A transactions~%" filename (length transactions))
     (dolist (entity transactions)
       (destructuring-bind (&key from-account-id from-amount
                                 to-account-id to-amount
@@ -182,4 +182,4 @@
 (defun on-cron ()
   (handler-case
       (import-financisto-events (find-last-backup))
-    (error (e) (princ e))))
+    (error (e) (log:error e))))

+ 2 - 2
src/foursquare.lisp

@@ -55,6 +55,6 @@
                                                  :asc nil :limit 1))))
              (from (and last-checkin (ms->ts (cl-mongo::raw (get-element "ts" last-checkin)))))
              (checkins (load-checkins from)))
-        (format t "Got ~A checkins from ~A~%" (length checkins) from)
+        (log:info "Got ~A checkins from ~A~%" (length checkins) from)
         (save-events checkins))
-    (error (e) (princ e))))
+    (error (e) (log:error e))))

+ 4 - 4
src/locations.lisp

@@ -95,7 +95,7 @@
        for locs = (docs->locs (docs (db.sort "locations" (ts->kv "timestampMs" ts) :field "timestampMs" :limit 1500)))
        for places = (extract-places locs)
        when places do
-         (format t "Inserting ~A places for ~A~%" (length places) ts)
+         (log:info "Inserting ~A places for ~A~%" (length places) ts)
          (save-places places)
        until (local-time:timestamp> ts now)
        finally (return ts))))
@@ -163,11 +163,11 @@
   (let* ((*google-cookie-jar* (load-chrome-cookie-jar ".google.com"))
          (*google-manual-header* (get-history-xsrf-token))
          (locs (load-history from to nil)))
-    (format t "Saving ~A locations for ~A~%" (length locs) from)
+    (log:info "Saving ~A locations for ~A~%" (length locs) from)
     (save-locations locs)
     (let* ((with-prev-locs (load-locations (local-time:timestamp- from 400 :sec) to))
            (places (extract-places with-prev-locs)))
-      (format t "Saving ~A place events~%" (length places))
+      (log:info "Saving ~A place events~%" (length places))
       (save-places places))))
 
 (defun find-location-at (ms)
@@ -203,4 +203,4 @@
                   (local-time:timestamp+ from 3 :day)
                   (local-time:now))))
         (import-location-events from to))
-    (error (e) (princ e))))
+    (error (e) (log:error e))))

+ 2 - 2
src/twitter.lisp

@@ -54,6 +54,6 @@
                                               :asc nil :limit 1))))
              (since-id (if last-twit (get-element "twitter.id" last-twit) 1))
              (twits (load-twits since-id)))
-        (format t "Got ~A twits from ~A~%" (length twits) since-id)
+        (log:info "Got ~A twits from ~A~%" (length twits) since-id)
         (save-events twits))
-    (error (e) (princ e))))
+    (error (e) (log:error e))))

+ 1 - 0
src/web.lisp

@@ -36,6 +36,7 @@
       (restas:context-add-variable
        context '*cron-timers*
        (loop for (function schedule) in *crons*
+          do (log:info "Starting cron" function schedule)
           collect
             (clon:schedule-function function
                                     (clon:make-scheduler

+ 2 - 1
timeliner.asd

@@ -50,7 +50,8 @@ THE SOFTWARE.
                :gzip-stream
                :clon
                :cl-oauth
-               :cl-date-time-parser)
+               :cl-date-time-parser
+               :log4cl)
   :components ((:module "src"
                 :components
                 ((:file "utils")