<commit_before>(in-package #:eloquent.mvc.logger)

(defun make-destination (label log)
  (merge-pathnames (concatenate 'string (string-downcase (symbol-name label)) ".log")
                   (log-directory log)))

(defun now ()
  "Return a string represents the current time, in the format YYYY-MM-DD hh:mm:ss."
  (local-time:format-timestring
   nil
   (local-time:universal-to-timestamp (get-universal-time))
   :format '((:year 2) "-" (:month 2) "-" (:day 2) " " (:hour 2) ":" (:min 2) ":" (:sec 2) " " :gmt-offset-hhmm)))

;;; EXPORT

(defun format (label control-string &rest format-arguments)
  "Like function CL:FORMAT but output the formatted string into a file named by LABEL."
  (declare (type keyword label))
  (let ((destination (make-destination label *log*))
        (fmt (concatenate 'string "~A: " control-string)))
    (with-open-file (stream destination
                            :direction :output
                            :if-exists :append
                            :if-does-not-exist :create)
      (apply #'cl:format stream fmt (now) format-arguments))))<commit_msg>Change the output format of access.log<commit_after>(in-package #:eloquent.mvc.logger)

(defun make-destination (label log)
  (merge-pathnames (concatenate 'string (string-downcase (symbol-name label)) ".log")
                   (log-directory log)))

(defun now ()
  "Return a string represents the current time, in the format YYYY-MM-DD hh:mm:ss."
  (local-time:format-timestring
   nil
   (local-time:universal-to-timestamp (get-universal-time))
   :format '((:year 2) "-" (:month 2) "-" (:day 2) " " (:hour 2) ":" (:min 2) ":" (:sec 2) " " :gmt-offset-hhmm)))

;;; EXPORT

(defun format (label control-string &rest format-arguments)
  "Like function CL:FORMAT but output the formatted string into a file named by LABEL."
  (declare (type keyword label))
  (let ((destination (make-destination label *log*)))
    (with-open-file (stream destination
                            :direction :output
                            :if-exists :append
                            :if-does-not-exist :create)
      (apply #'cl:format stream control-string format-arguments))))
{'fraction_non_alphanumeric': 0.14681440443213298, 'fraction_numerical': 0.00554016620498615, 'mean_word_length': 2.8151408450704225, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4702397', 'n_tokens_mistral': 690, 'n_tokens_neox': 656, 'n_words': 192}