Commit 82363869 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

Add (guix jupyter logging).

* guix/jupyter/logging.scm: New file.
* Makefile.am (SOURCES): Add it.
parent 6446ff08
......@@ -21,6 +21,7 @@ moddir=@guilemoduledir@
godir=@guileobjectdir@
SOURCES = \
guix/jupyter/logging.scm \
jupyter/json.scm \
jupyter/messages.scm \
jupyter/kernels.scm \
......
;;; Guix-kernel -- Guix kernel for Jupyter
;;; Copyright (C) 2019 Ludovic Courtès <ludovic.courtes@inria.fr>
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation, either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
(define-module (guix jupyter logging)
#:export (current-logging-port
format/log))
(define current-logging-port
;; Logging port, for debugging.
(make-parameter (current-error-port)))
(define-syntax format/log
(lambda (s)
"Log the given string."
(syntax-case s ()
((_ fmt args ...)
(string? (syntax->datum #'fmt))
(with-syntax ((fmt (string-append "guix[~a]: " (syntax->datum #'fmt))))
#'(format (current-logging-port) fmt
(getpid) args ...))))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment