Commits

seanmcl  committed b26e9e3

broke logs by date

  • Participants
  • Parent commits b959d9e

Comments (0)

Files changed (8)

+new stuff
+=========
+
+- Automatic compilation, unit testing, and regression tests via check.sh
+- Run omake_server.exe on a file (omake_server.exe server file FILE [-debug])
+
+changes
+=======
+
+- moved logs around and broke them up by date to be more organized.
+
+bug fixes
+=========
+
+- Performance improvement for big builds via computing error hashes on the
+  ocaml side and caching string representation of errors on the elisp side.
+
+--------------------------------------------------------------------------------
 
 new stuff
 =========

File elisp/omake/omake-errors.el

 (defun Omake.Errors.get-bug-desc (callback)
   (lexical-let*
       ((callback callback)
-       (header 
+       (header
         (concat
          "-------------------------------------------------------\n"
          "Please describe the problem.  Type C-x # when finished.\n"
          "-------------------------------------------------------\n\n"))
        (start (length header))
-       (finish 
+       (finish
         (lambda ()
           (interactive)
           (funcall callback (buffer-substring start (point-max)))
                             (desc (format "User report:\n%s" (String.escape-quotes desc)))
                             (body (format "%s\n\n%s" loc desc))
                             (file (format "%s/%s" dir "user-report")))
-                       (with-temp-buffer 
+                       (with-temp-buffer
                          (insert desc)
                          (write-region nil nil file))
                        (Mail.send :recipients recipients
                                   :subject subject
                                   :body body))))
          (copy
-          (lambda (f name) 
+          (lambda (f name)
             (Omake.ignore-errors
               (copy-file f (expand-file-name name dir)))))
          (copy-buf
-          (lambda (b name) 
+          (lambda (b name)
             (Omake.ignore-errors
               (with-current-buffer b (write-file name))))))
       (message "Collecting bug files")
       (funcall copy Omake.File.server-log "server-log")
       (funcall copy Omake.File.server-state "server-state.el")
-      (funcall copy Omake.File.mode-log "mode-log")
+      (funcall copy (Omake.File.emacs-log) "emacs-log")
       (funcall copy (Omake.File.raw id) "raw")
       (funcall copy (Omake.File.elisp id) "elisp")
       (funcall copy (Omake.File.project-log id) "project-log")

File elisp/omake/omake-file.el

 (defconst Omake.File.top
   (format "%s/%s" Omake.File.root Omake.user))
 
+(defconst Omake.File.log-dir
+  (expand-file-name "log" Omake.File.top))
+
+(defconst Omake.File.server-log-dir
+  (expand-file-name "server" Omake.File.log-dir))
+
 (defconst Omake.File.server-log
-  (expand-file-name "server-log" Omake.File.top))
+  (expand-file-name "current" Omake.File.server-log-dir))
 
 (defconst Omake.File.server-state
   (expand-file-name "server-state.el" Omake.File.top))
 
-(defconst Omake.File.mode-log-dir
-  (expand-file-name "mode-log" Omake.File.top))
+(defconst Omake.File.emacs-log-dir
+  (expand-file-name "emacs" Omake.File.log-dir))
+
+(defconst Omake.File.emacs-log-pid-dir
+  (format "%s/%d" Omake.File.emacs-log-dir (emacs-pid)))
 
 (condition-case _
-    (make-directory Omake.File.mode-log-dir t)
-  (error "Couldn't create the Omake mode-log.  Check the permissions on %s"
+    (make-directory Omake.File.emacs-log-pid-dir t)
+  (error "Couldn't create the Omake emacs-log.  Check the permissions on %s"
          Omake.File.root))
 
-(defconst Omake.File.mode-log
-  (format "%s/%d" Omake.File.mode-log-dir (emacs-pid)))
+(defun Omake.File.emacs-log ()
+  (format "%s/%s"
+          Omake.File.emacs-log-pid-dir
+          (format-time-string "%Y-%m-%d" (current-time))))
+;; (Omake.File.emacs-log)
 
 (defconst Omake.File.socket
   (format "%s/%s/socket" Omake.File.root Omake.user))

File elisp/omake/omake-server.el

   (apply 'Log.printf (cons (Omake.Buffer.get 'mode-log) (cons fmt rest)))
   (with-temp-buffer
     (insert (apply 'format (cons fmt rest)) "\n")
-    (write-region nil nil Omake.File.mode-log t 'no-message)))
+    (write-region nil nil (Omake.File.emacs-log) t 'no-message)))
 ;; (Omake.Server.logf "sean: %s %d" "abc" 8)
 
 (defun Omake.Server.running-p ()

File ocaml/omake/files.ml

 let project_file name id =
   sprintf "%s/%s" (project_dir id) name
 
+let server_log_dir = sprintf "%s/log/server" root
+let _ = Shell.mkdir ~p:() server_log_dir
+
 let omake = project_file "omake"
 let elisp = project_file "elisp.el"
 let log = project_file "log"
 let env = project_file "env"
-let server_log = sprintf "%s/server-log" root
+let server_log () =
+  let date = Date.to_string (Date.today ()) in
+  sprintf "%s/%s" server_log_dir date
+
 let socket = sprintf "%s/socket" root
 let server_state = sprintf "%s/server-state.el" root
 

File ocaml/omake/files.mli

 val log           : Id.t -> path
 val env           : Id.t -> path
 val server_state  : path
-val server_log    : path
+val server_log    : unit -> path
 val socket        : path
 val omakeroot_dir : path -> path option

File ocaml/omake/log.ml

 
 open Std
 
-let log_writer = lazy (Writer.open_file ~append:true Files.server_log)
+type t = { mutable path : path option
+         ; mutable writer : Writer.t }
 
-let wait () = Lazy.force log_writer >>| ignore
+let t = { path = None
+        ; writer = Lazy.force Writer.stdout }
+
+let log_writer () =
+  let log = Files.server_log () in
+  let has_writer = is_some t.path in
+  if t.path = Some log then return t.writer
+  else
+    begin
+      t.path <- Some log;
+      Writer.open_file ~append:true (Files.server_log ()) >>= fun writer ->
+      (if has_writer then Writer.close t.writer else Deferred.unit) >>| fun () ->
+      t.writer <- writer;
+      writer
+    end
+
+let wait () = log_writer () >>| ignore
 
 let time_prefix () = sprintf "[%s]" (Time.to_string (Time.now ()))
 
 let msg s = sprintf "%s %s\n" (time_prefix()) s
 
 let printf fmt =
-  match Deferred.peek (Lazy.force log_writer) with
+  match Deferred.peek (log_writer ()) with
   | None ->
     eprintf "WARNING: no log writer.  Writing to stderr.\n";
     ksprintf (fun s -> eprintf "%s" (msg s)) fmt

File ocaml/omake/std.ml

   module Array = Array
   module Bool = Bool
   module Command = Core_extended.Core_command
+  module Date = Date
   module Doubly_linked = Doubly_linked
   module Filename = Filename
   module Hash_set = Hash_set
   module Time = Time
   module Unix = Unix
   include Result.Export
+  let is_some = is_some
   let string_of_sexp = string_of_sexp
   let sexp_of_string = sexp_of_string
   let bool_of_sexp = bool_of_sexp