Skip to content

Add section about logging #85

@agorgl

Description

@agorgl

Currently, the book mentions that babashka includes clojure.tools.logging and timbre for logging.
Adding an example usage, would be a nice addition:

#!/usr/bin/env bb
(ns script
  (:require
   [clojure.tools.logging :as log]
   [taoensso.timbre :as timbre]))

(defn -main [& args]
  (log/info "Hello there"))

(when (= *file* (System/getProperty "babashka.file"))
  (apply -main *command-line-args*))

; vim: set ft=clojure:

We should also mention, that because timbre does a dns call to resolve the hostname, the hostname must exist in /etc/hosts to avoid slow (5sec) startup times:

# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1        localhost <your-hostname>
::1              localhost <your-hostname>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions