services: cuirass: Add SQL queries logging support.

* gnu/services/cuirass.scm (<cuirass-configuration>)[queries-log-file]: New
field.
(cuirass-shepherd-service): Honor it.
(cuirass-log-rotations): If defined, add the queries log file to the log
rotation.
This commit is contained in:
Mathieu Othacehe 2020-09-24 10:47:22 +02:00
parent e503211105
commit 92e507c963
No known key found for this signature in database
GPG key ID: 8354763531769CA6
2 changed files with 23 additions and 4 deletions

View file

@ -23904,6 +23904,10 @@ Location of the log file.
@item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"}) @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
Location of the log file used by the web interface. Location of the log file used by the web interface.
@item @code{queries-log-file} (default: @code{#f})
Location of the SQL queries log file. By default, SQL queries logging is
disabled.
@item @code{cache-directory} (default: @code{"/var/cache/cuirass"}) @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
Location of the repository cache. Location of the repository cache.

View file

@ -54,6 +54,8 @@ (define-record-type* <cuirass-configuration>
(default "/var/log/cuirass.log")) (default "/var/log/cuirass.log"))
(web-log-file cuirass-configuration-web-log-file ;string (web-log-file cuirass-configuration-web-log-file ;string
(default "/var/log/cuirass-web.log")) (default "/var/log/cuirass-web.log"))
(queries-log-file cuirass-configuration-queries-log-file ;string
(default #f))
(cache-directory cuirass-configuration-cache-directory ;string (dir-name) (cache-directory cuirass-configuration-cache-directory ;string (dir-name)
(default "/var/cache/cuirass")) (default "/var/cache/cuirass"))
(ttl cuirass-configuration-ttl ;integer (ttl cuirass-configuration-ttl ;integer
@ -87,6 +89,7 @@ (define (cuirass-shepherd-service config)
(cache-directory (cuirass-configuration-cache-directory config)) (cache-directory (cuirass-configuration-cache-directory config))
(web-log-file (cuirass-configuration-web-log-file config)) (web-log-file (cuirass-configuration-web-log-file config))
(log-file (cuirass-configuration-log-file config)) (log-file (cuirass-configuration-log-file config))
(queries-log-file (cuirass-configuration-queries-log-file config))
(user (cuirass-configuration-user config)) (user (cuirass-configuration-user config))
(group (cuirass-configuration-group config)) (group (cuirass-configuration-group config))
(interval (cuirass-configuration-interval config)) (interval (cuirass-configuration-interval config))
@ -111,6 +114,10 @@ (define (cuirass-shepherd-service config)
"--database" #$database "--database" #$database
"--ttl" #$(string-append (number->string ttl) "s") "--ttl" #$(string-append (number->string ttl) "s")
"--interval" #$(number->string interval) "--interval" #$(number->string interval)
#$@(if queries-log-file
(list (string-append "--log-queries="
queries-log-file))
'())
#$@(if use-substitutes? '("--use-substitutes") '()) #$@(if use-substitutes? '("--use-substitutes") '())
#$@(if one-shot? '("--one-shot") '()) #$@(if one-shot? '("--one-shot") '())
#$@(if fallback? '("--fallback") '()) #$@(if fallback? '("--fallback") '())
@ -140,6 +147,10 @@ (define (cuirass-shepherd-service config)
"--port" #$(number->string port) "--port" #$(number->string port)
"--listen" #$host "--listen" #$host
"--interval" #$(number->string interval) "--interval" #$(number->string interval)
#$@(if queries-log-file
(list (string-append "--log-queries="
queries-log-file))
'())
#$@(if use-substitutes? '("--use-substitutes") '()) #$@(if use-substitutes? '("--use-substitutes") '())
#$@(if fallback? '("--fallback") '()) #$@(if fallback? '("--fallback") '())
#$@extra-options) #$@extra-options)
@ -187,10 +198,14 @@ (define (cuirass-activation config)
(define (cuirass-log-rotations config) (define (cuirass-log-rotations config)
"Return the list of log rotations that corresponds to CONFIG." "Return the list of log rotations that corresponds to CONFIG."
(list (log-rotation (let ((queries-log-file (cuirass-configuration-queries-log-file config)))
(files (list (cuirass-configuration-log-file config))) (list (log-rotation
(frequency 'weekly) (files `(,(cuirass-configuration-log-file config)
(options '("rotate 40"))))) ;worth keeping ,@(if queries-log-file
(list queries-log-file)
'())))
(frequency 'weekly)
(options '("rotate 40")))))) ;worth keeping
(define cuirass-service-type (define cuirass-service-type
(service-type (service-type