Default --logfile to pgloader.log within --root-dir.

This commit is contained in:
Dimitri Fontaine 2013-11-21 14:28:11 +01:00
parent 516bb28ec0
commit 1419a1f65d

View File

@ -44,7 +44,7 @@
(("list-encodings" #\E) :type boolean
:documentation "List pgloader known encodings and exit.")
(("logfile" #\L) :type string :initial-value ,*log-filename*
(("logfile" #\L) :type string
:documentation "Filename where to send the logs.")
(("load" #\l) :type string :list t :optional t
@ -69,6 +69,20 @@
(format stream "PANIC: ~a.~%" e))
(uiop:quit))))
(defun log-file-name (logfile)
" If the logfile has not been given by the user, default to using
pgloader.log within *root-dir*."
(cond ((null logfile)
(make-pathname :directory (directory-namestring *root-dir*)
:name "pgloader"
:type "log"))
((fad:pathname-relative-p logfile)
(merge-pathnames logfile *root-dir*))
(t
logfile)))
(defun main (argv)
"Entry point when building an executable image with buildapp"
(let ((args (rest argv)))
@ -121,10 +135,7 @@
;; Now process the arguments
(when arguments
;; Start the logs system
(let ((logfile
(if (fad:pathname-relative-p logfile)
(merge-pathnames logfile *root-dir*)
logfile))
(let ((logfile (log-file-name logfile))
(log-min-messages
(log-threshold log-min-messages
:quiet quiet :verbose verbose :debug debug))