diff options
author | Mathieu Othacehe <othacehe@gnu.org> | 2020-09-22 15:17:31 +0200 |
---|---|---|
committer | Mathieu Othacehe <othacehe@gnu.org> | 2020-09-24 10:24:02 +0200 |
commit | b310f17aaff8f17af0e7cf77b0b9d6866fe89abe (patch) | |
tree | be8e63d1c3cfe386df224be37b2fbd2d7c4c50d0 /bin | |
parent | e7bebbe3d4bbd9103b8a2e71e62dfbaef9a928ab (diff) | |
download | cuirass-b310f17aaff8f17af0e7cf77b0b9d6866fe89abe.tar cuirass-b310f17aaff8f17af0e7cf77b0b9d6866fe89abe.tar.gz |
Add SQL query logging support.
* bin/cuirass.in (show-help): Document "--log-queries" option.
(%options): Add it.
(main): Enable query logging if the above option is set.
* src/cuirass/database.scm (db-log-queries): New procedure.
* src/cuirass/logging.scm (query-logging-port): New parameter.
(log-query): New procedure.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/cuirass.in | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bin/cuirass.in b/bin/cuirass.in index ed21ed7..c322a71 100644 --- a/bin/cuirass.in +++ b/bin/cuirass.in @@ -27,6 +27,7 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" ;;; along with Cuirass. If not, see <http://www.gnu.org/licenses/>. (use-modules (cuirass) + (cuirass base) (cuirass ui) (cuirass logging) (cuirass metrics) @@ -54,6 +55,7 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" -p --port=NUM Port of the HTTP server. --listen=HOST Listen on the network interface for HOST -I, --interval=N Wait N seconds between each poll + --log-queries=FILE Log SQL queries in FILE. --use-substitutes Allow usage of pre-built substitutes --record-events Record events for distribution --threads=N Use up to N kernel threads @@ -74,6 +76,7 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" (use-substitutes (value #f)) (threads (value #t)) (fallback (value #f)) + (log-queries (value #t)) (record-events (value #f)) (ttl (value #t)) (version (single-char #\V) (value #f)) @@ -111,10 +114,11 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" (else (mkdir-p (%gc-root-directory)) (let ((one-shot? (option-ref opts 'one-shot #f)) - (port (string->number (option-ref opts 'port "8080"))) - (host (option-ref opts 'listen "localhost")) - (interval (string->number (option-ref opts 'interval "300"))) - (specfile (option-ref opts 'specifications #f)) + (port (string->number (option-ref opts 'port "8080"))) + (host (option-ref opts 'listen "localhost")) + (interval (string->number (option-ref opts 'interval "300"))) + (specfile (option-ref opts 'specifications #f)) + (queries-file (option-ref opts 'log-queries #f)) ;; Since our work is mostly I/O-bound, default to a maximum of 4 ;; kernel threads. Going beyond that can increase overhead (GC @@ -139,6 +143,11 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@" (set-current-module (make-user-module '())) (primitive-load specfile))))) (for-each db-add-specification new-specs))) + + (when queries-file + (log-message "Enable SQL query logging.") + (db-log-queries queries-file)) + (if one-shot? (process-specs (db-get-specifications)) (let ((exit-channel (make-channel))) |